簡體   English   中英

iOS 更新推送內容擴展

[英]iOS update push in content extension

當 iMessage 出現在屏幕上時,它會更新豐富的推送。 您現在可以看到用戶正在輸入什么,並且消息將添加到您的對話中。

所以問題是:當我已經在查看打開的豐富推送時,我如何捕捉新的推送通知? to catch the new one and update view? 是否有任何事件可以捕獲新的並更新視圖? 我知道的唯一一個是:

- (void)didReceiveNotification:(UNNotification *)notification

但是只有第一次打開推送才會觸發iMessage 豐富推送

編輯:

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

所以它應該可以工作,但無論如何我都無法捕捉到這個事件。 也許我需要以某種方式使新通知與當前顯示“相關”?

想出問題出在哪里。

蘋果文檔:

顯示通知時,系統會在視覺上將具有相同線程標識符的通知分組在一起。 對於遠程通知,此屬性的值設置為 aps 字典中 thread-id 鍵的值。

將鍵“thread-id”添加到 aps 字典后,此函數現在可以正確接收事件

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM