gpt4 book ai didi

ios - 更改推送通知警报消息

转载 作者:可可西里 更新时间:2023-11-01 01:22:20 25 4
gpt4 key购买 nike

如何更改推送通知的提醒消息。我需要处理 Unicode 字符串,如屏幕截图所示。 screenshot

我尝试检查我的通知服务扩展,但找不到任何方法来处理 userInfo["alert"] 属性。

最佳答案

尝试更改您的通知服务扩展代码:

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)
}
}

关于ios - 更改推送通知警报消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43294051/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com