Migrate to the Next-Gen MobilePush SDK for iOS

The MobilePush SDK version 8.x update sets a more modern architectural foundation to enable a variety of improvements and all new features for future versions. The updated MobilePush SDK is designed with existing MobilePush customers in mind so that the upgrade path is light and straightforward.

To migrate to MobilePush SDK version 8 and above, follow these steps.

  1. Remove the existing CocoaPods dependency before adding MarketingCloudSDK from Swift Package Manager (MobilePush).
  2. Add the MobilePush dependency (tag 8.x) to your application target.
  • Until MobilePush SDK version 8.0.13, you must add SFMCSDK (tag 1.x) and MobilePush (tag 8.x) dependencies to your application target.

  • Ensure you manually pull the Resources/MarketingCloudSDK.bundle from the sources folder in the MarketingCloudSDK Swift module and add it as a resource within Copy Bundle Resources in the build phase configuration. Failing to do so results in the following error.

You must replace your existing initialization function to reference the new SDK. After you’ve fetched the updated SDK version in your project, the functions that must be modified are highlighted in your codebase.

  1. Update the configuration builder function as shown in the following example.

  2. Ensure that the SDK has initialized correctly by using a check on the status of initialization or by using the completion handler, as shown in the following example.

  1. Set the identity or ID of a known user: Replace your current identity tracking function setContactKey with the updated function setProfileID.

  2. Set the Attributes of a user: Replace your existing identity tracking function setAttribute with the updated function setProfileAttributes.

Align your existing functions with updated functions provided by the new SDK. All existing functions that need changes are marked as deprecated in your codebase.

If you’re using version 8.1.x of the SDK, you don't need to perform this step. Using the new requestPushSdk API enables the SDK to automatically capture notifications for you, regardless of the application’s state and the SDK initialization status. For a complete implementation example, see the iOS LearningApp.

To ensure push notifications are processed accurately when your application isn't actively running, capture them during application launch and store them in memory until the SDK initializes fully. Failing to do so prevents the SDK from processing incoming push notifications. After the SDK is operational, the notification is set to the SDK using setNotificationUserInfo API, as shown in the following example.

For a complete implementation example, see the iOS LearningApp.