Reputation: 1074
How do I change push notification's alert message. I need to process the Unicode string as shown in the screenshot.
I tried checking my notification service extension but I couldn't find any way to process the userInfo["alert"] property.
Upvotes: 2
Views: 978
Reputation: 4391
Try change you notification service extension code:
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
if let bestAttemptContent = bestAttemptContent {
// Modify the notification content here
// Convert received string
let data = bestAttemptContent.body.data(using: .utf8)!
// Apply encoded string
bestAttemptContent.body = String(data: data, encoding: .utf16)
contentHandler(bestAttemptContent)
}
}
Upvotes: 2