1 /* 2 * This class allows you to intercept and mutate incoming remote notifications. 3 * didReceive() has ~30 seconds to modify the payload and call the contentHandler, 4 * otherwise the system will display the notification’s original content. 5 * 6 * The notification payload must contain: 7 * "mutable-content" : 1 8 * "alert" : { ... } 9 * to trigger this handler. 10 */ 11 12 import UserNotifications 13 14 class NotificationService: UNNotificationServiceExtension { 15 override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { 16 if let bestAttemptContent = request.content.mutableCopy() as? UNMutableNotificationContent { 17 // Modify notification content here... 18 if !request.content.categoryIdentifier.isEmpty && (request.content.userInfo["experienceId"]) != nil { 19 bestAttemptContent.categoryIdentifier = EXScopedNotificationsUtils.scopedIdentifier(fromId: request.content.categoryIdentifier, forExperience: request.content.userInfo["experienceId"] as! String) 20 } 21 contentHandler(bestAttemptContent) 22 } 23 } 24 } 25