Latest 5.2.3
Homepage https://github.com/infobip/mobile-messaging-sdk-ios
License MIT
Platforms ios 9.0, requires ARC
Authors ,

Mobile Messaging SDK for iOS

Version
License
Platform

Mobile Messaging SDK is designed and developed to easily enable push notification channel in your mobile application. In almost no time of implementation you get push notification in your application and access to the features of Infobip Mobile Apps Messaging. The document describes library integration steps. Additional information can be found in our Wiki.

Requirements

  • Xcode 10
  • Swift 4.2
  • iOS 9.0+

Quick start guide

This guide is designed to get you up and running with Mobile Messaging SDK integrated into your iOS application.

  1. Make sure to setup application at Infobip portal, if you haven’t already.

  2. Configure your project to support Push Notifications:

    1. Click on "Capabilities", then turn on Push Notifications. Entitlements file should be automatically created by Xcode with set aps-environment value.

      Enable Push Notifications capability

    2. Turn on Background Modes and check the Remote notifications checkbox.
      Enable Remote Notifications in Background Modes settings
  3. Using CocoaPods, specify it in your Podfile:

    source 'https://github.com/CocoaPods/Specs.git'
    platform :ios, '9.0'
    use_frameworks!
    pod 'MobileMessaging'

    Notice

    CocoaLumberjack logging used by default, in order to use other logging or switch it off follow this guide.

    If you use Carthage, see Integration via Carthage guide.

  4. Import the library into your AppDelegate file:

    // Swift
    import MobileMessaging
    expand to see Objective-C code

    “`objective-c
    @import MobileMessaging;
    “`

  5. Start MobileMessaging service using your Infobip Application Code, obtained in step 1, and preferable notification type as parameters:

    // Swift
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        MobileMessaging.withApplicationCode(<#your application code#>, notificationType: <#for example UserNotificationType(options: [.alert, .sound])#>)?.start()
        ...
    }   
    expand to see Objective-C code

    “`objective-c
    – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    UserNotificationType *userNotificationType = [[UserNotificationType alloc] initWithOptions:;
    [[MobileMessaging withApplicationCode: notificationType: userNotificationType] start:nil];

    }
    “`

    Please note that it is not very secure to keep your API key (Application Code is an API key in fact) hardcoded so if the security is a crucial aspect, consider obfuscating the Application Code string (we can recommend UAObfuscatedString for string obfuscation).

  6. 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)
    }
    expand to see Objective-C code

    “`objective-c
    – (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [MobileMessaging didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
    }
    “`

  7. 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)
    }
    expand to see Objective-C code

    “`objective-c
    – (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler {
    [MobileMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
    }
    “`

  8. Integrate Notification Service Extension into your app in order to obtain:

    • more accurate processing of messages and delivery stats
    • support of rich notifications on the lock screen
  9. Skip this step if your apps minimum deployment target is iOS 10 or later. Override method application:didReceiveLocalNotification(for Objective-C) or application:didReceive:(for Swift) 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)
    }
    expand to see Objective-C code

    “`objective-c
    -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
    [MobileMessaging didReceiveLocalNotification:notification];
    }
    “`

    In case of a clean project, your AppDeleage.swift code should look like following:

    AppDelegate source code example

If all the steps implemented correctly, run your application on a real device, you should see the logs in Xcode console confirming that the MobileMessaging SDK has been initialized succesfully and the device has been registered on APNS to receive Push messages:

2019-01-28 18:24:16:003 [MobileMessaging] ℹ️ SDK successfully initialized!
...
2019-01-28 18:25:44:144 [MobileMessaging] ℹ️ [APNS reg manager] Application did register with device token <...>

If you don’t see any logs, set up the default logger before starting the SDK: MobileMessaging.logger = MMDefaultLogger(). Please note that the logs are only collected while your project is in "debug" configuration.

Please pay close attention to a Provisioning Profile that is used for your project build. It must match the APNs environment! If they don’t, we’ll invalidate the device push registration (more information here I don’t receive push notifications!

NEXT STEPS: User profile

If you have any questions or suggestions, feel free to send an email to [email protected] or create an issue.

Latest podspec

{
    "name": "MobileMessaging",
    "version": "5.2.3",
    "summary": "Mobile Messaging SDK for iOS",
    "description": "Mobile Messaging SDK is designed and developed to easily enable push notification channel in your mobile application. In almost no time of implementation you get push notification in you application and access to the features of Infobip IP Messaging Platform.",
    "homepage": "https://github.com/infobip/mobile-messaging-sdk-ios",
    "license": "MIT",
    "authors": {
        "Andrey Kadochnikov": "[email protected]",
        "Olga Koroleva": "[email protected]"
    },
    "source": {
        "git": "https://github.com/infobip/mobile-messaging-sdk-ios.git",
        "tag": "5.2.3"
    },
    "social_media_url": "https://twitter.com/infobip",
    "platforms": {
        "ios": "9.0"
    },
    "swift_version": "4.2",
    "requires_arc": true,
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4.2",
        "OTHER_SWIFT_FLAGS[config=Debug]": "-DDEBUG"
    },
    "default_subspecs": "CocoaLumberjack",
    "module_map": "MobileMessaging.modulemap",
    "subspecs": [
        {
            "name": "Core",
            "frameworks": [
                "CoreData",
                "CoreTelephony",
                "SystemConfiguration"
            ],
            "resources": [
                "Classes/InteractiveNotifications/MessageAlert/*.xib",
                "Classes/MessageStorage/*.xcdatamodeld",
                "Classes/Core/InternalStorage/*.xcdatamodeld",
                "Classes/Core/InternalStorage/*.xcmappingmodel",
                "Classes/InteractiveNotifications/*.plist",
                "Classes/Core/Localization/**/*.strings"
            ],
            "public_header_files": [
                "Classes/Core/**/*.h",
                "Classes/MobileMessaging-umbrella.h"
            ],
            "private_header_files": "Classes/Vendor/**/*.h",
            "source_files": [
                "Classes/Core/**/*.{h,m,swift}",
                "Classes/Vendor/**/*.{h,m,swift}",
                "Classes/MessageStorage/**/*.{h,m,swift}",
                "Classes/RichNotifications/**",
                "Classes/InteractiveNotifications/**/*.{h,m,swift}",
                "Classes/MobileMessaging-umbrella.h"
            ]
        },
        {
            "name": "CocoaLumberjack",
            "dependencies": {
                "MobileMessaging/Core": [],
                "CocoaLumberjack": [
                    "3.4.2"
                ]
            },
            "source_files": "Classes/Logging/CocoaLumberjack/**/*.{h,m,swift}"
        },
        {
            "name": "Geofencing",
            "dependencies": {
                "MobileMessaging/Core": []
            },
            "frameworks": "CoreLocation",
            "source_files": "Classes/Geofencing/**/*.{h,m,swift}"
        },
        {
            "name": "MobileChat",
            "frameworks": "AudioToolbox",
            "dependencies": {
                "MobileMessaging/Core": []
            },
            "source_files": "Classes/Chat/**/*.{h,m,swift}",
            "resource_bundles": {
                "MobileMessaging": [
                    "Classes/Chat/UI/Resources/**/*.{xcassets,png}"
                ]
            }
        }
    ]
}

Pin It on Pinterest

Share This