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.
- Add the New iOS SDK Build
- Initialize the SDK
- Update Identity Functions
- Update Remaining Functions
- Capture Notifications On Launch (Only for 8.0.x)
- Remove the existing CocoaPods dependency before adding
MarketingCloudSDKfrom Swift Package Manager (MobilePush). - Add the
MobilePushdependency (tag8.x) to your application target.
-
Until MobilePush SDK version 8.0.13, you must add
SFMCSDK(tag1.x) andMobilePush(tag8.x) dependencies to your application target. -
Ensure you manually pull the
Resources/MarketingCloudSDK.bundlefrom thesourcesfolder in theMarketingCloudSDKSwift 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.
-
Update the configuration builder function as shown in the following example.
-
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.
-
Set the identity or ID of a known user: Replace your current identity tracking function
setContactKeywith the updated functionsetProfileID. -
Set the Attributes of a user: Replace your existing identity tracking function
setAttributewith the updated functionsetProfileAttributes.
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.