Skip to content

Latest commit

 

History

History
144 lines (115 loc) · 6.5 KB

README.md

File metadata and controls

144 lines (115 loc) · 6.5 KB

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. The document describes library integration steps.

Requirements

  • Xcode 8.1+
  • iOS 8.4+

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. To integrate MobileMessaging into your Xcode project using CocoaPods, specify it in your Podfile:

    source 'https://github.com/CocoaPods/Specs.git'
    platform :ios, '8.4'
    use_frameworks!
    pod 'MobileMessaging'
  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

    Notice

    MobileMessaging SDK has geofencing service disabled by default. In order to enable the service follow this guide.

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: UIUserNotificationType {
    	return <# your notification types preference, i.e. [.Alert, .Sound] #>
    }
    // Objective-C
    -(NSString *)applicationCode {
    	return <# your application code #>";
    }
    -(UIUserNotificationType)userNotificationType {
    	return <# your notification types preference, i.e. UIUserNotificationTypeAlert | UIUserNotificationTypeSound #>;
    }
  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 Telephone 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#>
}];