logo indigitall
All topics / SDK Integration / App Integration

App Integration

Our Software Development Kit for your app.

iOS SDK

Introduction

This section provides the basic information to setup the indigitall SDK in your app.

It will be necessary to have the identifier required so that the app, in which you want to integrate the SDK, can communicate with the Indigitall environment. To receive this identifier the developer must provide to indigitall the necessary data to send the notifications (.p12 certificate for notifications) obtained from the Apple Developer Console.

The following tutorial explains how to get these certificates. How to obtain the “.cer”and “.p12”from APNS.

Notification Service Extension

Since iOS 10 apps can manage rich push notifications. In order to do this the app needs implements a Notification Service Extension.

Once created the extension it creates a new file inside this new target called NotificationService. Override all the content with the next code:


import Indigitall
class NotificationService: INNotificationServiceExtension {}
#import <Indigitall/Indigitall-Swift.h>
@interface NotificationService (INNotificationServiceExtension)
@end

Installation

indigitall SDK is available through Cocoapods.

$ gem install cocoapods


$ pod init


target '<YourTarget>' do
  pod 'indigitall-ios'
end
target '<YourTargetNotificationExtension>' do
    pod 'indigitall-ios'  
end


$ pod repo update


$ pod install


Since this point use the .workspace instead of the .xcproject to work in your project

Capabilities

You must activate the Push Notifications and, in Background Modes activate Location updates, Background Fetch and Remote notifications.


ios


AppDelegate

The initialization of the indigitall library is made by modifying the AppDelegate file. It should be as follows:


import Indigitall
#import <Indigitall/Indigitall-Swift.h>



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        Indigitall.initialize(appKey: "<YOUR-APPKEY>")
        return true
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [IndigitallObjc initializeWithAppKey:@"<YOUR-APPKEY>" success:nil failed:nil];
    return YES;
}



func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        Indigitall.set(deviceToken)
}
func application(_ application: UIApplication, didReceiveRemoteNotification data: [AnyHashable : Any]) {
        Indigitall.handle(notification: data)
}
func application(_ application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [AnyHashable : Any], completionHandler: @escaping () -> Void) {
        Indigitall.handle(notification: userInfo, identifier: identifier)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        Indigitall.handle(notification: userInfo)
        completionHandler(.newData)
}
- (void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
    [IndigitallObjc setWithDeviceToken:deviceToken];
}
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo{
    [IndigitallObjc handleWithNotification:userInfo identifier:nil];
}                                                                                                                                                         
- (void) application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(nonnull NSDictionary *)userInfo completionHandler:(nonnull void (^)())completionHandler{
    [IndigitallObjc handleWithNotification:userInfo identifier:identifier];
}
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
    [IndigitallObjc handleWithNotification:userInfo identifier:nil];
}



func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        Indigitall.performFetchWithCompletionHandler(completionHandler: completionHandler)
}
- (void) application:(UIApplication *)application performFetchWithCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
    [IndigitallObjc performFetchWithCompletionHandlerWithCompletionHandler:completionHandler];
}


Further steps

Now you will see in logs how indigitall register your device. Search the word "deviceId" and get it value. It is an alphanumeric random and uniq id generated for indigitall.


deviceIdAndroid

Now you can send your first Notification

Segment your users:

More references