DIAnalytics 0.1.5

DIAnalytics 0.1.5

Maintained by Mathieu Juneau, Mathieu Juneau.



 
Depends on:
Firebase/Core~> 6.0
Firebase/Messaging~> 6.0
Firebase/Analytics~> 6.0
 

  • By
  • Dialog Insight

DIAnalytics

Version License Platform

Requirements

  • Firebase Project
  • Firebase Cloud Messaging configured in Firebase console. For more information, refer to Firebase Cloud Messaging docs
  • Firebase project's "GoogleService-Info.plist".
  • Application ID provided by Dialog Insight

Installation

DIAnalytics is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "DIAnalytics"

Usage

  1. Add your "GoogleService-Info.plist" provided by Firebase to the root of your project. Ensure that the file is in the "Copy Bundle Resources" of your target project.

  2. Add the following code to your AppDelegate:

#pragma mark - Notification delegate

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    [DIAnalytics handleDidReceiveRemoteNotification:userInfo];

    if (application.applicationState == UIApplicationStateActive ) {
        NSLog(@"Application is in foreground when it received the notification, application should handle display of notification.");
    }
}

//For iOS under 10, you must implement these two methods to register for a token
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    NSLog(@"Unable to register for remote notifications: %@", error);
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [DIAnalytics handleDidRegisterForRemoteNotificationWithDeviceToken:deviceToken];
}
  1. Setup your preference.
[DIAnalytics setLogEnabled:YES];
[DIAnalytics setBaseUrl:@"https://ofsys.com"];
  1. Start the library with your ApplicationID provided by Dialog Insight in your "didFinishLaunchingWithOptions" implementation.
[DIAnalytics startWithApplicationId:@"MY_APPLICATION_ID_PROVIDED_BY_DIALOG_INSIGHT" withLaunchOptions:launchOptions];
  1. Send information about the user.

    In order to identify a user of the application as a contact of your DI project, you must provide the information corresponding to the fields of the unique key.

    Note: the DI fields always start with a "f_". In the DI project fields page, look at the fields tagged as “primary field” and note their code. In the following steps, just prepend “f_” with any field code. For instance, a DI field with the code “idCustomer” will become “f_idCustomer”.

    This is made in two simples step. First, gather the primary key fields informations in a dictionary.

    For example, a project where the unique key is composed only of the EMail field, do:

    NSMutableDictionary *customFieldsDictionary = [[NSMutableDictionary alloc] init];
    [customFieldsDictionary setObject:self.emailTextField.text forKey:@"f_EMail"];

    For a project where the unique key is composed of the fields FirstName and LastName, do:

    NSMutableDictionary *customFieldsDictionary = [[NSMutableDictionary alloc] init];
    [customFieldsDictionary setObject:self.firstNameTextField.text forKey:@"f_FirstName"];
    [customFieldsDictionary setObject:self.nameTextField.text forKey:@"f_LastName"];

    For a project where the unique key is composed only of a field named “idCustomer”, do:

    NSMutableDictionary *customFieldsDictionary = [[NSMutableDictionary alloc] init];
    [customFieldsDictionary setObject:self.idCustomerTextField.text forKey:@"f_idCustomer"];

    Then, make another dictionary with a “contact” entry and send it.

    NSDictionary *contactDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:customFieldsDictionary, @"contact", nil];
    
    [DIAnalytics identify:contactDictionary];
  2. Register for push notification. This will prompt to user an UIAlertView asking to authorize notifications.

[DIAnalytics registeForRemoteNotification];

Authors

Dialog Insight, [email protected]

License