Rich Notifications is a notification type which supports image, gif, video content. D·engage SDK supports varieties of contents and handles notification.
Supports:
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
1.2 Select Notification Service Extension then press Next.
1.3 Enter the product name as DengageNotificationServiceExtension and press Finish.
1.4 Press Cancel on the Activate scheme prompt.
1.5 Open NotificationService.swift and replace the whole file contents with the below code.
Swift
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 #available(iOS 15.0, *) {
bestAttemptContent?.interruptionLevel = .timeSensitive
} else {
}
Dengage.didReceiveNotificationRequest(
bestAttemptContent,
withContentHandler: contentHandler
)
}
override func serviceExtensionTimeWillExpire() {
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
contentHandler(bestAttemptContent)
}
}
}
1.6 It should be added to the PodFile.