If you have not completed the initial integration step, you cannot proceed with this article. Refer to one of the following articles to complete the initial integration steps:
Provide native support for your Kount solution by integrating the Kount iOS SDK (version 4.1.5) into your Objective-C iOS application. This allows you to use Kount's service without having to create API calls. Software for this integration can be found in GitHub.
Invoking the Kount iOS SDK 4.1.5 into Objective-C
- Download and extract the contents of the SDK from the GitHub.
- Copy libKountDataCollector.a from the Kount SDK and add it in your iOS project. Place the KountDataCollector folder from the Kount SDK inside the folder structure of your iOS project.
- Add KountDataCollector to header search paths:
- Go to Project Target, Build Settings, and then Header Search Paths.
- Add Header search path as ../KountDataCollector.
- Add the folder for touch event related files (for reference) under Project target:
- Go to the Project Navigator view.
- Right-click your app’s project name, and then select Add files to “{Project}”.
- From the Finder window, select KountDataCollector.
- Under KountDataCollector, select folder TouchControls – which contains touch events related files – and then click Add.
- For iOS 13
Under SceneDelegate.h, add:#import “KountAnalyticsViewController.h”
Under SceneDelegate.m, in the sceneDidEnterBackground method, add:
#import “KDataCollector.h”KountAnalyticsViewController *backgroundTaskObject = [[KountAnalyticsViewController alloc] init];
[backgroundTaskObject registerBackgroundTask];] - For iOS versions less than 13
Under AppDelegate.h, add:#import "KountAnalyticsViewController.h"
Under AppDelegate.m, in the ApplicationDidEnterBackground method, add:
#import "KDataCollector.h”KountAnalyticsViewController *backgroundTaskObject = [[KountAnalyticsViewController alloc] init];
[backgroundTaskObject registerBackgroundTask];NOTE: For each view in which you want to send Analytics data, in the .h file you must add:#import “KountAnalyticsViewController.h”
- In m, write the following code snippet:
NSString *sessionID = nil;
[[KDataCollector sharedCollector] setDebug:YES];
// Set your Merchant ID
[[KDataCollector sharedCollector] setMerchantID:99999];
// Set the location collection configuration
[[KDataCollector sharedCollector] setLocationCollectorConfig:KLocationCollectorConfigRequestPermission];
// For a released app, you'll want to set this to KEnvironmentProduction
[[KDataCollector sharedCollector] setEnvironment:KEnvironmentTest];
[[KountAnalyticsViewController sharedInstance] setEnvironmentForAnalytics: [KDataCollector.sharedCollector environment]];
//To collect Analytics Data, set Boolean flag - analyticsData to YES.
BOOL analyticsData = YES;
[[KountAnalyticsViewController sharedInstance] collect:sessionID analyticsSwitch:analyticsData completion:^(NSString * _Nonnull sessionID, _Bool success, NSError * _Nullable error) {
//Completion block to know whether device data collection is successful/failed with error/failed without error.
if (success) {
NSLog(@"Collection Successful");
}
else {
if(error != nil) {
NSLog(@"Collection failed with error:%@",error.description);
}
else {
NSLog(@"Collection failed without error");
}
}
}];
- In the viewcontrollers where you want to detect events, in the .h file add:
#import KountAnalyticsViewController.h
Replace the UIViewController inheritance with KountAnalyticsViewController, and then remove UITextFieldDelegate (if any).
NOTE: If your view controller does not inherit directly from UIViewController, perform this step on the controller that does inherit from UIViewController, and make sure the controller calls super.init(). - In the view controllers where you want to capture analytics data, under the ViewDidLoad method, add:
<textfield_Name>.delegate = self
NOTE: It must be added for all textfields on that page.In the login view controller’s .m file inside the code for Successful login, add:
[[KountAnalyticsViewController sharedInstance] storeLogInEvents:YES];
Inside the code for Unsuccessful login add:[[KountAnalyticsViewController sharedInstance] storeLogInEvents:NO];
NOTE: If a ViewController in the application overrides the method that is being used for capturing analytics data, then call[super <MethodName>]
in the ViewController method.
- Almost all Kount API calls require your Kount assigned merchantID and a sessionID (getAppSessionID). You must send the KountAnalyticsViewController.getAppSessionID back to your servers. This can be done any time prior to the Kount API calls being made from your servers to ours. For example, if you are using Kount Control and plan to evaluate logins, you could include the KountAnalyticsViewController.getAppSessionID along with the user’s login credentials to your servers.
NOTE: Refer to the Kount Integration Guide for more information. - Build and Run.
NOTE: For iOS versions greater than or equal to 13, if your application is using segues, then analytics data will capture for that view controller only if modal is presented using UIModalPresentationFullScreen. For iOS version less than 13, the default presentation style is already full screen, so no changes are necessary and analytics data will capture for those screens.
Comments
0 comments
Article is closed for comments.