Send Rich Notifications
Prerequisites
- Make sure that your iOS app is built for iOS 10 or 11.
- Include a service extension for your app that can handle mutable content. See Apple’s documentation.
- Update to version 4.9.6 or higher of the Journey Builder for Apps (JB4A) SDK, which supports iOS 10.
- Make sure that your app is registered for push notifications via the MarketingCloudSDK.
Rich notifications include images, videos, titles and subtitles from the MobilePush app, and mutable content. Mutable content can include personalization in the title, subtitle, or body of your message. Use Xcode 9 from Apple to create a Notification Service Extension in your application project.
- Click File.
- Click New.
- Click Target.
- Select Notification Service Extension.
- Name and save the new extension.
- Verify in your project target’s general settings that the new extension was added to the
Frameworks, Libraries, and Embedded Content
section. If not present, please add it.
Note: Notification Target must be signed by the same XCode Managed Profile as the main project.
Service Extension Example
This service extension checks for a “_mediaUrl” element in request.content.userInfo. If found, the extension attempts to download the media from the URL , creates a thumbnail-size version, and then adds the attachment. The service extension also checks for a ““_mediaAlt” element in request.content.userInfo. If found, the service extension uses the element for the body text if there are any problems downloading or creating the media attachment.
A service extension can timeout when it is unable to download. In this code sample, the service extension delivers the original content with the body text changed to the value in “_mediaAlt”.