【发布时间】:2017-04-08 12:23:39
【问题描述】:
【问题讨论】:
-
好问题,我从来没有遇到过这样的问题...(y)
【问题讨论】:
尝试更改您的通知服务扩展代码:
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)
}
}
【讨论】:
body 有效,那么就使用它。我只是以title 为例,因为它取决于您的 PN 实现。
body,如果它对您有帮助,您也可以为答案投票:)