【问题标题】:iOS update push in content extensioniOS 更新推送内容扩展
【发布时间】:2017-03-15 14:06:29
【问题描述】:

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;

所以它应该可以工作,但我无论如何都无法捕捉到这个事件。也许我需要以某种方式使新通知与当前显示“相关”?

【问题讨论】:

    标签: ios objective-c swift push-notification notification-content-extension


    【解决方案1】:

    发现问题出在哪里。

    苹果文档:

    显示通知时,系统可视化分组 具有相同线程标识符的通知一起。对于远程 通知,此属性的值设置为 aps 字典中的 thread-id 键。

    在 aps 字典中添加键“thread-id”后,此函数现在可以正确接收事件

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-09-23
      • 2012-03-01
      • 2021-12-21
      • 1970-01-01
      • 1970-01-01
      • 2018-06-26
      • 1970-01-01
      相关资源
      最近更新 更多