Skip to content

Integration via app delegate composition

Andrey Kadochnikov edited this page Aug 10, 2016 · 15 revisions
  1. Import the library:

    // Swift
    import MobileMessaging
    // Objective-C
    @import MobileMessaging;
  2. Start MobileMessaging service using your Infobip Application Code, obtained in step 2, and preferable notification type as parameters:

    // Swift
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
            MobileMessaging.withApplicationCode("your_application_code", notificationType: [.Alert, .Sound]).start()
    	...
    }	
    // Objective-C
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
            [[[MobileMessaging withApplicationCode: @"your_application_code" notificationType: (UIUserNotificationTypeAlert | UIUserNotificationTypeSound)] withGeofencingServiceDisabled:self.geofencingServiceDisabled] start:nil];
    	...
    }
  3. Override method application:didRegisterForRemoteNotificationsWithDeviceToken: in order to inform Infobip about the new device registered:

    // Swift
    func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
    	MobileMessaging.didRegisterForRemoteNotificationsWithDeviceToken(deviceToken)
    }
    // Objective-C
    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    	[MobileMessaging didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
    }
  4. Override method application:didReceiveRemoteNotification:fetchCompletionHandler: in order to send notification delivery reports to Infobip:

    // Swift
    func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
    	MobileMessaging.didReceiveRemoteNotification(userInfo, fetchCompletionHandler: completionHandler)
    }
    // Objective-C
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
    	[MobileMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
    }
Clone this wiki locally