当我发送带有推送负载
编辑1:问题似乎出现在使用10.2.1系统的特定设备上,我在另一台运行10.2系统的设备上进行了检查,它触发了通知服务扩展。
mutable-content: 1
的通知时,通知未显示,也没有命中通知服务扩展中的断点,尽管没有可变内容推送被显示,但通知内容扩展正常工作。我没有修改通知服务扩展内部的代码,它是由Xcode默认生成的。在创建通知服务扩展时,我是否遗漏了某些东西,或者可能是设备设置的问题?几天前,我在同一设备上进行了测试,通知服务扩展正常工作。
下面是我的服务扩展代码:import UserNotifications
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
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...
bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"
contentHandler(bestAttemptContent)
}
}
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 {
contentHandler(bestAttemptContent)
}
}
}
编辑1:以下是我的推送负载
{
"aps":{
"sound":"default",
"mutable-content": 1,
"category": "myCategory",
"alert":{
"body":"this is a custom push",
"subtitle":"subtitle of the push",
"title":"Push Test"
}
}
}
编辑1:问题似乎出现在使用10.2.1系统的特定设备上,我在另一台运行10.2系统的设备上进行了检查,它触发了通知服务扩展。