iOS update push in content extension

时光总嘲笑我的痴心妄想 提交于 2020-03-21 05:16:13

问题


iMessage updates the rich push when it's on the screen. You can see what is user is typing RIGHT NOW, and message will be added to your conversation.

So the question is: how i can catch new push notification, when i'm already looking at opened rich push? Is there any event in UNNotificationContentExtension to catch the new one and update view? The only one i know is:

- (void)didReceiveNotification:(UNNotification *)notification

but it is triggered only when you open the push first time

Edit:

Found that in UNNotificationContentExtension protocol:

// 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;

So it should work but i can't catch this event anyway. Maybe i need somehow to make new notification "related" to currently displayed?


回答1:


Figured where's was the problem.

Apple docs:

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.

After adding key "thread-id" to aps dictionary, this func now receiving events correctly

- (void)didReceiveNotification:(UNNotification *)notification;


来源:https://stackoverflow.com/questions/42812113/ios-update-push-in-content-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!