add ios notification example

This commit is contained in:
Salvatore Giordano
2020-03-27 11:07:32 +01:00
parent 1de4fa37a8
commit 24e32f891e
6 changed files with 46 additions and 40 deletions
@@ -19,16 +19,14 @@ class NotificationService: UNNotificationServiceExtension {
defer {
contentHandler(bestAttemptContent ?? request.content)
}
print("DID RECEIVE NOTIFICATION")
// Modify the notification content here...
bestAttemptContent?.title = "\(bestAttemptContent?.title ?? "<NoContent>") [modified]"
// Modify the notification content here...
bestAttemptContent?.title = "[modified] \(bestAttemptContent?.title ?? "<NoContent>")"
}
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 {
bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"
contentHandler(bestAttemptContent)
}
}