Integrate the iOS SDK

You can integrate the Mobile App Messaging SDK into your iOS app to enable push notifications and user engagement features.

Add the Mobile App Messaging SDK dependencies to your project. There are three ways to add these dependencies:

Complete one of these processes before you continue.

The configuration example in this section uses the MarketingCloudSDK ConfigBuilder configuration method. This method is the most flexible way to use the Mobile App Messaging SDK.

All method names contain the prefix sfmc_. Using this prefix helps avoid namespace collisions between the external libraries it uses. For more information, see Apple Developer Documentation: Customizing Existing Classes.

Configure the SDK in your application using mamAppID, mamAccessToken, mamServerURL, and mamTenantId.

iOS Data Protection affects the SDK as described in this table.

iOS Data Protection LevelSDK Behavior
No protectionSDK works in the foreground and background.
Complete until first user authenticationSDK works in the foreground and background after first unlock.
Complete unless openSDK works in the foreground and background after first unlock.
CompleteSDK works only in the foreground after the device is unlocked.

Before you enable push notifications, provision your app for push notifications.

  1. Enable push notifications in your target’s Capabilities settings.

  2. Set your AppDelegate class to adhere to the UIApplicationDelegate and UNUserNotificationCenterDelegate protocol.

  3. Extend the SDK configuration code outlined in Configure the SDK to add support for push registration.

  4. Add the required UIApplicationDelegate protocol methods to support push registration to your AppDelegate class.

  5. Add the required UNUserNotificationCenterDelegate protocol methods to support push notifications to your AppDelegate class.