Knowledgebase
IOS - SDK & Implementation Guide
Posted by Innometrics Profile Cloud on 11 Feb 2016 18:00

Below guide can be downloaded here IOS - SDK & Implementation Guide.pdf

Method References

http://public.innomdc.com/ios-library/method-references/annotated.html

Requirements

  • iOS 5.0 and above
  • include SystemConfiguration.framework and libsqlite3.dylib

Include library

  1. Download iOS library and include it into your project (In XCode drag'n'drop Innometrics.framework folder to "frameworks") 
  2. Create config file innometrics_config.plist in the project root. Values for config you can find in the GUI: Install "iOS Data Collection" app, create first section (name of your ios app), go to Settings tab.

Example of config file:

 <?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0">

<dict>

<key>innometrics_company_id</key> <string>1</string><key>innometrics_bucket</key>             <string>bucketname</string><key>innometrics_section</key>      <string>sectionname</string><key>innometrics_app_key</key>            <string>appkey</string><key>innometrics_events_limit</key>       <integer>1000</integer><key>innometrics_debug</key>              <false/>

</dict>

</plist>

  1.       Before using InnometricsAPI you need to include header file InnometricsAPI.h and get instance of InnometricsAPI class:

 #import <Innometrics/InnometricsAPI.h>

               

 InnometricsAPI *api = [InnometricsAPI sharedManager];

 

Send data to profile

  1.       To track user events call InnometricsAPI method - (void)trackEvent:(NSString *)eventDefinition data:(NSDictionary *)eventData. It takes two arguments: eventDefinition - name of the event, eventData - dictionary containing parameters of this event.

For instance to collect data about searches done by user you can use this code:

- (IBAction) clickSearch:(id)sender {

NSMutableDictionary *temp = [NSMutableDictionary dictionary];

    [temp setObject:@"search type" forKey:[self searchType]];

    [temp setObject:@"search string" forKey:[self searchString]];

    NSString *eventName = @"eventSearch";

    [api trackEvent:eventName data:temp];

}

 

  1.       To set profile attribute use setAttributeWithKey, it creates new attribute in current collect application and section, or overrides it if attribute with the same key already exists. 
  2.       Session data could be set with setSessionDataWithKey
  3.       Also, there is a possibility to track exceptions with (void)trackException:(NSException *)caughtException method: 

@try {

NSArray *emptyArray = @[];

NSObject *obj = [emptyArray objectAtIndex:0];

[obj description]; // Suppress warning

}

@catch (NSException *exception){

[api trackException:exception];

}

or - (void)trackError:(NSError *)userError

NSError *jsonParseError = nil;

[NSJSONSerialization JSONObjectWithData:[badJSonString dataUsingEncoding:NSUTF8StringEncoding]

options:0

error:&jsonParseError

];

[api trackError:jsonParseError]; 

Profiles identification and merging

Terms:

  • temporary profile ID used in case user isn't authenticated
  • canonical profile ID - user is authenticated in your system.

By default, when you init library (first time get instance of InnometricsAPI) it generates temporary profile ID with md5 from identifierForVendor.

It's unique for each of mobile user within one Vendor.

If you want you can set your own temporary ID with setTemporaryProfileId.

Once your user is authenticated, you need to set canonical id with (void)setCanonicalProfileId:(NSString *)profileId and then merge data of temporary profile into canonical with (void)mergeProfile.

Note: After that merged profile will be accessible by both IDs (temporary and canonical).

Debug

Debug messages can be enabled in innometrics_config.plist with  

 <key>innometrics_debug</key><true/>

Now you can see in XCode console log what data is sent to Profile Cloud, what profile ID is used and API URLs:

12:03:06.609 INNLog |

POST https://api.innomdc.com/v1/companies/<companyID>/buckets/<bucketName>/profiles/<profileID>?app_key=<appKey>&max_return_events=1000

IQL 

IQL - Innometrics Query Language is built to:

  • evaluate segments (return true or false for IQL expression)
  • and to search and filter data in profile

IQL runs in separate thread, so it needs callback to handle query result. To run IQL query call executeIQL:

 - (void) executeIQL: (NSString *) iql  withCallback: (IQLQueryBlock) block

After query execution IQLQueryBlock will be called and argument IQLResult will contain query result:

 [api

executeIQL:@"collectApp(\"web\").section(\"website.com\").event(\"page-view\").eventData(\"search-string\").neq(\"\").inLast(\"events.minute\",5)" withCallback:^(IQLResult *result, NSError *error)

{   

BOOL res = [result found];

INNLog(@"iql result %@", res);

}

Internal workflow

Every time application is minimized, library suspends its activity. If you want to suspend network activity of library while iOS app is active you can use methods

(void)suspendBackgroundSync and -(void)resumeBackgroundSyn—Ā.

In iOS library data is only sent to Profile Cloud (Android library has local copy of data). IQL execution performed on server. In case when network isn't available data stored locally. Config param innometrics_events_limit limits amount of data that could be stored locally and to limit memory usage for this case.

(0 vote(s))
Helpful
Not helpful

Comments (0)