Send Rich Notifications
Include images, videos, titles, and subtitles in your push notifications to create more engaging messages. Rich notifications use mutable content that can include personalization in the title, subtitle, or body of your message.
To use rich notifications, your app requires iOS 10 or later, a Notification Service Extension that handles mutable content, and registration for push notifications via the Salesforce Engagement SDK. The service extension downloads media from a URL, creates attachments, and handles fallback text if media fails to load.
Skip these steps if you’ve already integrated the Notification Service Extension.
- In Xcode, click File > New > Target.
- Select Notification Service Extension.
- Name and save the new extension.
- In your project target’s General settings, confirm that the new extension is listed in the Frameworks, Libraries, and Embedded Content section. If it isn’t, add it.
Sign the Notification Target with the same Xcode Managed Profile as the main project.
This service extension checks for a _mediaUrl element in request.content.userInfo. If the extension finds this element, it tries to download the media from the URL, creates a thumbnail 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 if it’s unable to download. In this code sample, the service extension delivers the original content with the body text changed to the value in _mediaAlt.