【发布时间】:2017-01-06 10:52:13
【问题描述】:
TL;DR: 需要在 APNs 通知负载 JSON 中设置什么键来对应 UNNotificationContent 对象的 threadIdentifier 属性?例如"category" 键对应于 categoryIdentifier 属性。
iOS 10 引入了Notification Content Extension,允许我们在展开通知时呈现视图控制器。
我们提供的视图控制器符合UNNotificationContentExtension 协议,这需要我们实现didReceive(_:) 方法。
此方法的文档包括以下段落:
当您的视图控制器可见时,此方法可能会被多次调用。具体来说,当一个新的通知到达时,它会再次被调用,它的 threadIdentifier 值与已经显示的通知的线程标识符匹配。
threadIdentifier 属性可以在代码中为本地通知设置,但我不知道如何为从服务器发送到 APN 的远程通知设置它。
UNNotificationContent 文档在此处描述了该属性:http://developer.apple.com/reference/usernotifications/unnotificationcontent
以下 JSON 包含我尝试过的密钥("thread" 和 "thread-identifier"):
{
"aps" : {
"alert" : "Hello World!",
"sound" : "default",
"category" : "example-category",
"thread" : "example-thread",
"thread-identifier" : "example-thread-identifier"
}
"custom-field" : "some value",
}
我找不到任何来自 Apple 的关于如何设置的文档。有人可以帮忙吗?
【问题讨论】:
标签: ios apple-push-notifications unnotificationrequest