Configure the Content Extension for the iOS Extension SDK
Set up and configure the Notification Content Extension for use with the iOS Extension for the Salesforce Engagement SDK.
The notification content extension is a bundle within your main app. To add a content extension target, complete these steps.
-
In Xcode, go to File > New > Target.
-
In the iOS > Application Extension section, select Notification Content Extension.
-
Click Next.
-
Configure the app extension and click Finish.
-
In the General Settings section for your project target, verify that the new extension is listed under Frameworks, Libraries, and Embedded Content. If it isn’t listed there, add it.
Use the same Xcode-managed profile for the extension targets as the main project. Match the content extension version to the main app version whenever possible, and prefix the content extension bundle ID with the main app’s bundle ID. For example, if the main app’s bundle ID is
com.salesforce.MyAwesomeApp, the content extension bundle ID can becom.salesforce.MyAwesomeApp.MyContentExtension.
To integrate the iOS Extension with the Content Extension, add the dependencies to CocoaPods or Swift Package Manager (SPM). You can also add the dependencies manually.
- Integrate the SDK with CocoaPods
- Integrate the SDK with Swift Package Manager (SPM)
- Integrate the SDK Manually
If you use CocoaPods to manage dependencies for your app, add the extension SDK to your Podfile.
- Update your Podfile to include the extension SDK.
- In your project directory, run
pod install. - Open the
.xcworkspacefile that CocoaPods generates.
Don’t open the .xcodeproj file directly. Opening a project file instead of a workspace can lead to errors.
For more information about updating Podfiles, see Using CocoaPods: Adding pods to an Xcode project on the CocoaPods documentation site.
If you use Swift Package Manager (SPM) to manage dependencies for your app, add the extension SDK to your project.
- On the Package Dependencies tab of your project’s settings, click the plus sign (+) to add a package.
- Search for the package
MCExtensionSDKusing the URLhttps://github.com/salesforce-marketingcloud/extension-sdk-ios.git - Select the package to include it in your app.
If you don’t use CocoaPods or Swift Package Manager, add the extension packages manually.
-
Download the MCExtensionSDK.
-
Copy the
MCExtensionSDKdirectory from your downloads folder to your project directory.To keep the binary in a different location, adjust the Framework Search Path (
FRAMEWORK_SEARCH_PATHS) in your build settings. -
In your project, select the Content Extension target.
-
In the General Settings for your project, in the Frameworks, Libraries, and Embedded Content section, add the
MCExtensionSDKframework.

After you add the dependencies to your project, inherit the main class of the Content Extension from the SFMCNotificationViewController class.
If your project is written in Swift, use this code to inherit the service.
If your project uses ObjectiveC, use this header.
In your ObjectiveC implementation file, use this code.
SFMCNotificationViewController fully manages UI rendering. Don’t implement or override any UIViewController methods in the principal class of the content extension, as doing so can interfere with UI rendering.
Configure your content extension’s Info.plist file to register the correct notification category, build the rich push notification UI in code using the Extension SDK, and enable user interaction. These steps make sure that the content extension is correctly triggered and displays the intended rich UI as defined in Marketing Cloud Engagement.
To set up and synchronize the notification category between your content extension’s Info.plist file and the Marketing Cloud Engagement UI:
- Contact your Marketing Cloud Engagement admin to obtain the correct category name for the Rich UI template.
- In your content extension’s
Info.plistfile, replace the value forUNNotificationExtensionCategoryunderNSExtension > NSExtensionAttributes.
iOS activates the content extension only if the category value in the push notification payload matches the one defined in Info.plist > NSExtension > NSExtensionAttributes > UNNotificationExtensionCategory. Make sure that the category value in Marketing Cloud Engagement matches the value in your content extension’s Info.plist file. Otherwise, the Carousel template won’t show.
Unlike Apple’s auto-generated content extension template, MCExtensionSDK builds the notification UI programmatically instead of using an Interface Builder file. To modify the project to build the rich push notification UI entirely in code using the MCExtensionSDK:
-
Remove the storyboard reference by deleting the
NSExtensionMainStoryboarditem fromInfo.plist > NSExtension. -
Add the
NSExtensionPrincipalClasskey toInfo.plist > NSExtension- Value type:
String - Value:
$(PRODUCT_MODULE_NAME).<MainClassName>
For Objective-C projects, specify the class name directly.
- Value type:
-
Remove
MainInterface.storyboardfrom your project.
Add this key to your content extension’s Info.plist file:
- Key:
UNNotificationExtensionUserInteractionEnabled - Value type: Boolean
- Value:
YES
The MCExtensionSDK manages the content extension lifecycle. You can customize some of the ways the extension behaves:
- Enabling or disabling logging and configuring log levels
- Adjusting the HTTP request timeout
If your project is written in Swift, implement the sfmcProvideConfig() method to define custom log levels and HTTP timeout settings for the extension.
If your project uses ObjectiveC, use the sfmcProvideConfig method to configure logging behavior and HTTP request timeout values for the extension.
The default timeout for network requests is 15 seconds. Additionally, iOS blocks insecure (non-HTTPS) URLs by default. To allow loading Carousel images from HTTP URLs, configure an exception.