Unliche SDK – iOS documentation

Last Updated On January 03, 2019
< Back

 


Getting started
Unliche SDK helps you to track application installs and custom events. We developed Unliche SDK to integrate easily and lightweight.


1. Embedding the SDK into Your Application (Mandatory)
The following steps are mandatory to measure installs and events.


1.1 Installing the SDK using CocoaPods
If project is not already using Cocoapods, you can follow the instructions on cocoapods.org to get up and running.

Add the following line to your pod file:

pod 'unliche'

1.2 Installing the SDK manually

  • In Xcode, go to Build Phases >> Link Binary with Libraries >> Click + to add a new library
  • Click Add Other and add the Unliche.framework
  • Or you can also go to Build Phases >> Embeded binaries >> Click + to add a new library >> Click Add Other and add the Unliche.framework

 

2. Add the required frameworks
Add the frameworks listed below. To add them, click your application’s target. Then click Build Phases, and Link Binary with Libraries to enter the frameworks.

  • AdSupport.framework

 

Note:
Unliche collects the IDFA, only if you include this framework.

3. Add Linker Flags
In XCode, under the Build Settings tab, you can either:

  • Choose All, and scroll down to the Linking section, and choose Other Linker Flags
  • Enter “other linker flags” in the search box

In the Other Linker Flags box, add the -ObjC flag.

4. SDK Initialisation and Installation Event (Minimum Requirement for Tracking)
Note: This is the minimum requirement to begin with the tracking of app installs.

4.1. Initialisation

  • Add #import <Unliche/Unliche.h> in App Delegate
  • To initialise the SDK, add the following to your “didFinishLaunchingWithOptions”function:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  [UnlicheManager initializeWithUnlicheAccessToken:@"e16220ba0cd50e296916875e6e7f8fe4" withEnvironmentType:UnlicheEnvironmentTypeProd];

  // Override point for customization after application launch.
  return YES;}

Note: SDK supports two environment modes.

1. UnlicheEnvironmentTypeProd (Default).
2. UnlicheEnvironmentTypeTest (Testing purpose).


4.2. Custom events(Advertiser defined events)
This API enables Unliche to track post install events. These events are defined by the advertiser and include an event id, in addition to optional event values. Tracking in-app events helps you measure and analyze how loyal users discover your app, and attribute them to specific campaigns/media sources.

[UnlicheManager trackEventWithEventId:1010];


4.3. Custom event with additional params

Add the following code to your source code file to track the custom events with additional parameters:

[UnlicheManager trackEventWithEventId:1010 withAdditionalParam1:@"Social" andParam2:@"12" 
andParam3:@"Usertype1" andParam4:@"120posts" andParam5:@"13likes"];

 

4.4. Enable Deep linking in your App.
At the time of initialisation, initialise the Unliche SDK with the below function.

HTML
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  [UnlicheManager initializeWithUnlicheAccessToken:@"e16220ba0cd50e296916875e6e7f8ase4" 
withAppStoreId:827828 withEnvironmentType:UnlicheEnvironmentTypeProd];

  // Override point for customization after application launch.
  return YES;
}

 

4.5 Send Category name with event
You can send the category name at the time of installation or on every event function. We added additional optional field ‘category name’ with every function wherever needed.

HTML
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  [UnlicheManager initializeWithUnlicheAccessToken:@"e16220ba0cd50e296916875e6e7f8ase4" withAppStoreId:827828 
withEnvironmentType:UnlicheEnvironmentTypeProd withCategoryName:"FASHION"];

  // Override point for customization after application launch.
  return YES;
}

 

4.6 Uninstall tracking
Unliche uninstall tracking feature allows to track the number of uninstalls that happened for particular app in the device and attribute them back to a specific media source. With this metric, you can optimize your advertising budget and strategy with those media sources providing the highest value users.

To enable uninstall tracking feature, you have to enable push notificatin feature in your application. And upload the .pem file which you generates with push in Unliche admin portal.

Please refer below link to enable push notification in your app :

Create a push notification certificate

After creating your .PEM file, upload the file into unliche server.
Select Menu -> Technical Config -> Key file -> In the page, Select the App -> Upload the .pem file and the password (if required).

Enable push notification service in your app by implementing the below code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  // Register for Remote Notifications
  [application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge
 | UIRemoteNotificationTypeSound)];
  
return YES;
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)
deviceToken{
  
// send device token to Unliche SDK
    [UnlicheManager application:application unlicheDidRegisterForRemoteNotificationsWithDeviceToken:deviceToken];

}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)
error {
   
 // send error if occured to Unliche SDK
  [UnlicheManager application:application unlicheDidFailToRegisterForRemoteNotificationsWithError:error];

}

 

5. Optional fields
If you want to pass the below additional params along with the events, please integrate the below methods in your app.

 

5.1. User ID
If you want to see the data of particular user for your app by user id, simply pass the user id of the user.

[UnlicheManager setUserID:@"user Id"];

 

5.2. User name
If you want to see the data of particular user for your app by user name, simply pass the user name of the user.

[UnlicheManager setUserName:@"user name"];

 

5.3. Phone number
If you want to see the data of particular user for your app by phone number, simply pass the phone number of the user.

HTML
[UnlicheManager setPhoneNumber:@"phone number"];

 

6. In-App Events Tracking Testing
If you want to test the events firing properly or not, you can test it by doing below steps.

  • Login to Unliche, define the events within your application.
  • Integrate the custom event tracking code in your iOS application.
  • Goto Event integration section under Technical Config from left side menu panel.
  • Select the application and click on ‘Validate now’ button for each event.
  • If the event status is Success and its matched with the timestamp then the event is getting fired successfully and if status is false then the event is not getting fired.

 

How to submit Your iOS app With IDFA
When submitting your app you have to disclose your IDFA uses:

  • Serve advertisements within the app.
    Please check this box if you show ads in your app. Unliche’s SDK is not used to serve ads.
  • Attribute this app installation to a previously served advertisement.
    Unliche uses IDFA for install attribution. Please select this check box.
  • Attribute an action taken within this app to a previously served advertisement
    Unliche uses IDFA for engagement ads attribution. Please select this check box.
  • iOS Limited Ad Tracking

The Unliche SDK collects the iOS “Limit Ad Tracking” (“advertisingTrackingEnabled”) flag when collecting IDFA. Unliche fully complies with Apple requirement: “Check the value of this property before performing any advertising tracking. If the value is NO, use the advertising identifier only for the following purposes: frequency capping, conversion events, estimating the number of unique users, security and fraud detection, and debugging.” Unliche uses IDFA only for: “conversion events, estimating the number of unique users, security and fraud detection”. The data is owned by our clients, the app developers, and Unliche never uses IDFA for user profiling and re-targeting.