Configure Marketing Cloud Engagement
Configure the Service Extension
Configure the Content Extension
Handle Carousel Notifications
Enable App Groups
Runtime Toggles
Event Tracking
Handle URLs
Data Protection and Privacy
Changelog
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 be com.salesforce.MyAwesomeApp.MyContentExtension.
Important
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.
If you use CocoaPods to manage dependencies for your app, add the extension SDK to your Podfile.
1target ‘<appTarget>’ do
2 use_frameworks!
3 pod ‘MarketingCloudSDK’
4end
5
6target ‘<appExtensionTarget>’ do
7 use_frameworks!
8 pod ‘MarketingCloud-ExtensionSDK’
9endpod install..xcworkspace file that CocoaPods generates.Don’t open the .xcodeproj file directly. Opening a project file instead of a workspace can lead to errors.
Important
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.
MCExtensionSDK using the URL https://github.com/salesforce-marketingcloud/extension-sdk-ios.gitIf you don’t use CocoaPods or Swift Package Manager, add the extension packages manually.
Download the MCExtensionSDK.
Copy the MCExtensionSDK directory 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.
Note
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 MCExtensionSDK framework.

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.
1import UIKit
2import UserNotifications
3import UserNotificationsUI
4import MCExtensionSDK
5
6class NotificationViewController: SFMCNotificationViewController { }If your project uses ObjectiveC, use this header.
1#import <UIKit/UIKit.h>
2#import <MCExtensionSDK/MCExtensionSDK.h>
3
4@interface NotificationViewController : SFMCNotificationViewController
5
6@endIn your ObjectiveC implementation file, use this code.
1#import "NotificationViewController.h"
2
3@implementation NotificationViewController
4
5@endSFMCNotificationViewController 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.
Warning
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:
Info.plist file, replace the value for UNNotificationExtensionCategory under NSExtension > 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.
Warning
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 NSExtensionMainStoryboard item from Info.plist > NSExtension.
Add the NSExtensionPrincipalClass key to Info.plist > NSExtension
String$(PRODUCT_MODULE_NAME).<MainClassName>For Objective-C projects, specify the class name directly.
Note
Remove MainInterface.storyboard from your project.
Add this key to your content extension’s Info.plist file:
UNNotificationExtensionUserInteractionEnabledYESThe MCExtensionSDK manages the content extension lifecycle. You can customize some of the ways the extension behaves:
If your project is written in Swift, implement the sfmcProvideConfig() method to define custom log levels and HTTP timeout settings for the extension.
1import UIKit
2import UserNotifications
3import UserNotificationsUI
4import MCExtensionSDK
5
6class NotificationViewController: SFMCNotificationViewController {
7
8 override func sfmcProvideConfig() -> SFContentExtensionConfig {
9 var logLevel: LogLevel = .none
10#if DEBUG
11 logLevel = .debug
12#endif
13 return SFContentExtensionConfig(logLevel: logLevel, timeoutIntervalForRequest: 30.0)
14 }
15}If your project uses ObjectiveC, use the sfmcProvideConfig method to configure logging behavior and HTTP request timeout values for the extension.
1#import "NotificationViewController.h"
2
3@implementation NotificationViewController
4
5- (SFMCContentExtensionConfig *)sfmcProvideConfig {
6 SFMCExtensionSdkLogLevel logLevel = SFMCExtensionSdkLogLevelNone;
7#if DEBUG
8 logLevel = SFMCExtensionSdkLogLevelDebug;
9#endif
10 return [[SFMCContentExtensionConfig alloc] initWithLogLevel:logLevel timeoutIntervalForRequest:30.0];
11}
12
13@endThe 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.
Note