Latest 3.4.0
Homepage https://github.com/infobip/mobile-messaging-sdk-ios
License MIT
Platforms ios 8.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 IP Messaging Platform. This document describes library integration steps. Additional information on advanced topics can be found in our wiki page.

Requirements

  • Xcode 9.0
  • iOS 8.0+

Quick start guide

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

  1. Prepare your App ID, provisioning profiles and APNs certificate (APNs Certificate Guide).
  2. Prepare your Infobip account (https://portal.infobip.com/push/) to get your Application Code:

    1. Create new application on Infobip Push portal.
    2. Navigate to your Application where you will get the Application Code.
    3. Mark the "Available on iOS" checkbox.
    4. Mark the "Sandbox" checkbox if you are using sandbox environment for the application.
    5. Click on "UPLOAD" under "APNS Certificates" and locate the .p12 certificate you exported from your Keychain earlier.

    CUP Settings
  3. 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.
    2. Turn on Background Modes and check the Remote notifications checkbox.
  4. Installation

    CocoaPods

    To integrate MobileMessaging into your Xcode project using CocoaPods, specify it in your Podfile:

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

    Notice

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

    Carthage

    If you use Carthage to manage your dependencies, just add MobileMessaging to your Cartfile:

    github "infobip/mobile-messaging-sdk-ios"

    If you use Carthage to build your dependencies, make sure you have added MobileMessaging.framework to the "Linked Frameworks and Libraries" section of your target, and have included them in your Carthage framework copying build phase (as described in Carthage documentation).
    If your application target does not contain Swift code at all, you should also set the EMBEDDED_CONTENT_CONTAINS_SWIFT build setting to “Yes”.

  5. Perform code modification to the app delegate in order to receive push notifications. There are two ways to do this: App Delegate Inheritance or App Delegate Composition

  6. At this step you are all set for receiving regular push notifications. There are several advanced features that you may find really useful for your product, though:

App Delegate Inheritance

The simplest approach to integrate Mobile Messaging with an existing app is by inheriting your app delegate from MobileMessagingAppDelegate. If you prefer a more advanced way: App Delegate Composition.

  1. Import the library, into your AppDelegate declaration file:

    // Swift
    import MobileMessaging
    // Objective-C
    @import MobileMessaging;
  2. Inherit your AppDelegate from MobileMessagingAppDelegate or MobileMessagingAppDelegateObjc depending on your project’s language:

    // Swift
    class AppDelegate: MobileMessagingAppDelegate {
        ...
    }
    // Objective-C
    @interface AppDelegate : MobileMessagingAppDelegateObjc
  3. Override applicationCode and userNotificationType variables in your AppDelegate providing appropriate values:

    // Swift
    override var applicationCode: String {
        return <# your application code #>
    }
    override var userNotificationType: UserNotificationType {
        return <#your notification types preference, i.e. UserNotificationType(options: [.alert, .sound])#>
    }
    // Objective-C
    -(NSString *)applicationCode {
        return <# your application code #>";
    }
    -(UserNotificationType)userNotificationType {
        <#return your notification types preference, i.e. [[UserNotificationType alloc] initWithOptions: @[UserNotificationType.alert, UserNotificationType.sound]];#>
    }
  4. If you have any of following application callbacks implemented in your AppDelegate:

    • application(:didFinishLaunchingWithOptions:)
    • application(:didRegisterForRemoteNotificationsWithDeviceToken:)
    • application(:didReceiveRemoteNotification:fetchCompletionHandler:)
    • application(:didReceive:) or application(:didReceiveLocalNotification:)

    , rename it to corresponding:

    • mm_application(:didFinishLaunchingWithOptions:)
    • mm_application(:didRegisterForRemoteNotificationsWithDeviceToken:)
    • mm_application(:didReceiveRemoteNotification:fetchCompletionHandler:)
    • mm_application(:didReceiveLocalNotification:)

Mobile Messaging APIs

Events

Library informs you about following events using NSNotificationCenter:

  • Message received – is triggered after a message has been received.
  • Device token received – is triggered after an APNS registration token has been received from APNS.
  • Registration updated – is triggered after an APNS registration token has been successfully stored on the server.
  • API error – is triggered on every error returned by API.
  • Delivery reports sent – is triggered after a message delivery has been reported.
  • Message will be sent – is triggered when a mobile originated message is about to be sent to the server.
  • Message did send – is triggered after a mobile originated message has been sent to the server.
  • etc.

More information on library events available on our wiki page.

Linking with MSISDN

It is recommended that you link the GSM number (in MSISDN format).
It will give an additional opportunity to target your application users and orchestrate your campaigns with OMNI Messaging service including SMS fallback feature.

// Swift
MobileMessaging.currentUser?.save(msisdn: <#for example "79091234567"#>, completion:
    { error in
        <#handle the error if needed#>
    }
)
// Objective-C
[[MobileMessaging currentUser] saveWithMsisdn: <#for example @"79091234567"#>
                                   completion: ^(NSError * _Nullable error)
{
    <#handle the error if needed#>
}];

Latest podspec

{
    "name": "MobileMessaging",
    "version": "3.4.0",
    "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": "3.4.0"
    },
    "social_media_url": "https://twitter.com/infobip",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4.0",
        "OTHER_SWIFT_FLAGS[config=Debug]": "-DDEBUG"
    },
    "default_subspecs": "CocoaLumberjack",
    "module_map": "MobileMessaging.modulemap",
    "subspecs": [
        {
            "name": "Core",
            "frameworks": [
                "CoreData",
                "CoreTelephony",
                "SystemConfiguration"
            ],
            "resources": [
                "Classes/MessageStorage/*.xcdatamodeld",
                "Classes/Core/InternalStorage/*.xcdatamodeld",
                "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.1"
                ]
            },
            "source_files": "Classes/Logging/CocoaLumberjack/**/*.{h,m,swift}"
        },
        {
            "name": "Geofencing",
            "dependencies": {
                "MobileMessaging/Core": []
            },
            "frameworks": "CoreLocation",
            "source_files": "Classes/Geofencing/**"
        }
    ]
}

Pin It on Pinterest

Share This