Installation

Step 1: Configure CocoaPod

Open Terminal and start CocoaPod on the project that you are working on.

cd /YourProject
pod init
nano Podfile

Place the “MessagingSDK” dependency

pod 'MessagingSDK'

Run the installation or update command as appropriate

pod install
# or
pod update

Open the workspace created by cocoapod for your project

open YourProject.xcworkspace

Step 2: Configure XCode Project

Select your project and go to the Signatures and Capabilities tab.

Select a valid device to configure the following capabilities:

  • Add Push Notifications

  • Add Background modes and enable the following:

  • Location updates

  • Add Keychain Sharing and set a keychain group name

com.messaging.MessagingSDK

image12.jpg

Step 3: Obtain Messaging-Info.plist file

Obtain the configuration file Messaging-Info.plist from the Mobile Messaging Platform. This is found in the Preferences section under the Push tab after completing the initial App Integration setup.

image7.png

Example of Messaging-Info.plist file:

<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
 <dict>
    <key>messagingHost</key><string>YourHost</string>
    <key>messagingAppToken</key><string>YourAppToken</string>
    <key>loggingEnable</key><false/>
    <key>locationEnable</key><false/>
    <key>analyticsEnable</key><false/>
 </dict>
</plist>

Once you have downloaded the requiredMessaging-Info.plistfile, enter the following values:

  • messagingHost string: it must contain the URL and host version of messaging.

  • messagingAppToken string:access code granted by messaging.

  • loggingEnable boolean: variable to activate or deactivate the logs from the SDK

  • locationEnableboolean: variable to activate or deactivate Location use in the SDK.

  • analyticsEnable boolean: variable to activate or deactivate the Analytics use in the SDK.

Step 4: Open the AppDelegate project file

Select your project and go to the Signatures and Capabilities tab. Select a valid device to configure the following capabilities:

Implicit Implementation

Open your AppDelegateimport MessagingSDK module and replace the parent classUIResponder and implementationUIApplicationDelegate withMessagingAppDelegate

import MessagingSDK
@UIApplicationMain
class AppDelegate: MessagingAppDelegate {                                
 // you can leave this empty if you're using a storyboard.
} 

Note

You can overwrite theMessagingAppDelegate methods in your AppDelegate, but remember to invoke the parent via super.

@UIApplicationMain
class AppDelegate: MessagingAppDelegate {                                        
override func application(_ application: UIApplication, didFinishLaunchingWithOptions 
   // your code
  return super.application(application, didFinishLaunchingWithOptions: launchOptions)
 } 
} 
Explicit Implementation

If you cannot do without the current parent class of your project, place the following invocations in the following methods of your AppDelegate.

In the applicationDidFinishLaunchingWithOptions method place MessagingImplementation.initialize(), in this manner:

override func application(_ application: UIApplication,
didFinishLaunchingWithOptions la
MessagingImplementation.initialize()
  // your code...
  return true                                        
} 

In the applicationDidRegisterForRemoteNotificationsWithDeviceToken method, place MessagingImplementation.indicate(pushToken: deviceToken), in this manner:

override func application(_ application: UIApplication, 
didRegisterForRemoteNotification 
MessagingImplementation.indicate(pushToken: deviceToken)                
} 

                                                   
override func applicationWillEnterForeground(_ application: UIApplication) { 
  MessagingImplementation.checkChanges()
                                                
} 

Also in method application(:didReceiveRemoteNotification:fetchCompletionHandler) placeMessagingImplementation.didReceiveRemoteNotification(:fetchCompletionHandler), this way:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [A MessagingngImplementation.didReceiveRemoteNotification(userInfo, fetchCompletionHand
}

Finally you can implement the MessagingNotificationDelegate interface in your AppDelegate class to manage what happens when a notification arrives.

...
class AppDelegate: ..., MessagingNotificationDelegate { 
  ...
}
...
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.