Sam*_*Sam 4 apple-push-notifications ios unnotificationrequest
TL; DR:需要在APNs通知有效负载JSON中设置哪些密钥才能对应对象的threadIdentifier属性UNNotificationContent?例如,"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",
}
Run Code Online (Sandbox Code Playgroud)
我找不到Apple提供的有关如何设置此文档的任何文档.有人可以帮忙吗?
Sam*_*Sam 12
我从Apple的一个联系人那里发现,填充这个属性的正确关键是"thread-id"关键.
所以发送给APN的JSON如下:
{
"aps" : {
"alert" : "Hello World!",
"sound" : "default",
"category" : "example-category",
"thread-id" : "my conversation blah blah"
}
"custom-field" : "some value",
}
Run Code Online (Sandbox Code Playgroud)
这将填充您的Notification Content Extension中可访问threadIdentifier的UNNotificationContent对象的属性notification.request.content.threadIdentifier.
通过设置此"thread-id"值,表示didReceive(_:)内容扩展的方法将多次.首先在最初扩展通知时,并且每当新通知以相同"thread-id"值到达时再次.
我认为(希望)一旦iOS 10正式发布,这将被添加到官方文档中.
| 归档时间: |
|
| 查看次数: |
3348 次 |
| 最近记录: |