iOS 内容扩展更新推送
iOS update push in content extension
iMessage 在屏幕上时更新丰富的推送。您可以看到用户现在正在输入什么,消息将添加到您的对话中。
所以问题是:当我已经在查看已打开的富推送时,我如何才能捕捉到新的推送通知? UNNotificationContentExtension 中是否有任何事件可以捕获新事件并更新视图?我唯一知道的是:
- (void)didReceiveNotification:(UNNotification *)notification
但是只有第一次打开推送才会触发
编辑:
发现在UNNotificationContentExtension协议中:
// This will be called to send the notification to be displayed by
// the extension. If the extension is being displayed and more related
// notifications arrive (eg. more messages for the same conversation)
// the same method will be called for each new notification.
- (void)didReceiveNotification:(UNNotification *)notification;
所以它应该可以工作,但我还是无法捕捉到这个事件。也许我需要以某种方式向当前显示的内容发送新通知 "related"?
找出问题所在。
Apple 文档:
When displaying notifications, the system visually groups
notifications with the same thread identifier together. For remote
notifications, the value of this property is set to the value of the
thread-id key in the aps dictionary.
将键 "thread-id" 添加到 aps 字典后,此函数现在可以正确接收事件
- (void)didReceiveNotification:(UNNotification *)notification;
iMessage 在屏幕上时更新丰富的推送。您可以看到用户现在正在输入什么,消息将添加到您的对话中。
所以问题是:当我已经在查看已打开的富推送时,我如何才能捕捉到新的推送通知? UNNotificationContentExtension 中是否有任何事件可以捕获新事件并更新视图?我唯一知道的是:
- (void)didReceiveNotification:(UNNotification *)notification
但是只有第一次打开推送才会触发
编辑:
发现在UNNotificationContentExtension协议中:
// This will be called to send the notification to be displayed by
// the extension. If the extension is being displayed and more related
// notifications arrive (eg. more messages for the same conversation)
// the same method will be called for each new notification.
- (void)didReceiveNotification:(UNNotification *)notification;
所以它应该可以工作,但我还是无法捕捉到这个事件。也许我需要以某种方式向当前显示的内容发送新通知 "related"?
找出问题所在。
Apple 文档:
When displaying notifications, the system visually groups notifications with the same thread identifier together. For remote notifications, the value of this property is set to the value of the thread-id key in the aps dictionary.
将键 "thread-id" 添加到 aps 字典后,此函数现在可以正确接收事件
- (void)didReceiveNotification:(UNNotification *)notification;