Rich Notifications

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.

Note: 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.

    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
        self.contentHandler = contentHandler
        bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
         
        if let bestAttemptContent = bestAttemptContent {
            
            // add this line of code
            Dengage.didReceiveNotificationExtentionRequest(receivedRequest: request, withNotificationContent: bestAttemptContent)
            contentHandler(bestAttemptContent)
        }
    }