Rich Notifications is a notification type which supports image, gif, video content. D·engage SDK supports varieties of contents and handles notification.
Supports:
- Image
- Video
- Gif
To support Rich Notifications, application needs to create Notification Service Extension.
on Android, there is no special setup required for rich notifications.
Referrer: Apple Doc
Referrer: Supported File Types
Setup
Adding Notification Service Extension
1.1 In Xcode Select File > New > Target
File > New > Target
1.2 Select Notification Service Extension
then press Next
.
Notification Service Extension
then press Next
.
1.3 Enter the product name as DengageNotificationServiceExtension
and press Finish
.
DengageNotificationServiceExtension
and press Finish
.
1.4 Press Cancel
on the Activate scheme prompt.
Cancel
on the Activate scheme prompt.
1.5 Open NotificationService.swift
and replace the whole file contents with the below code.
NotificationService.swift
and replace the whole file contents with the below code.
import UserNotifications
import Dengage
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
if let bestAttemptContent = bestAttemptContent {
Dengage.didReceiveNotificationRequest(bestAttemptContent, withContentHandler: contentHandler)
contentHandler(bestAttemptContent)
}
}
override func serviceExtensionTimeWillExpire() {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
contentHandler(bestAttemptContent)
}
}
}
1.6 It should be added to the PodFile.
target 'DengageNotificationServiceExtension' do
pod 'Dengage', :git => 'https://github.com/dengage-tech/dengage-ios-sdk.git', :branch => 'version/5.54.1'
end