Integration via app delegate composition - infobip/mobile-messaging-sdk-ios GitHub Wiki
-
Import the library:
// Swift import MobileMessaging// Objective-C @import MobileMessaging; -
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: <#for example MMUserNotificationType(options: [.alert, .sound])#>)?.start() ... }// Objective-C - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { MMUserNotificationType *userNotificationType = [[MMUserNotificationType alloc] initWithOptions:<#for example @[MMUserNotificationType.alert, MMUserNotificationType.sound]#>; [[MobileMessaging withApplicationCode: <#your application code#> notificationType: userNotificationType] start:nil]; ... } -
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]; } -
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]; } -
Override method
application:didReceiveLocalNotification(for Objective-C) orapplication:didReceive:(for Swift 3) in order the MobileMessaging SDK to be able to handle incoming local notifications internally:// Swift func application(_ application: UIApplication, didReceive notification: UILocalNotification) { MobileMessaging.didReceiveLocalNotification(notification) }// Objective-C -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { [MobileMessaging didReceiveLocalNotification:notification]; }