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 
16   override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
17     if let bestAttemptContent = request.content.mutableCopy() as? UNMutableNotificationContent {
18       // Modify notification content here...
19       if (!request.content.categoryIdentifier.isEmpty && (request.content.userInfo["experienceId"]) != nil) {
20         bestAttemptContent.categoryIdentifier = EXScopedNotificationsUtils.scopedIdentifier(fromId: request.content.categoryIdentifier, forExperience: request.content.userInfo["experienceId"] as! String)
21       }
22       contentHandler(bestAttemptContent)
23     }
24   }
25 
26 }
27