【问题标题】:Remotely remove previously sent notification远程删除之前发送的通知
【发布时间】:2016-12-22 18:09:34
【问题描述】:

从 iOS 10 和 UNUserNotificationCenter 开始,很多事情都可以通过通知实现,但我不知道如何远程删除推送通知每次

使用mutable-content 属性,我可以修改推送通知的内容。 但是假设我想稍后将其删除(内容已过期)。我使用了content-available,然后是以下代码:

UNUserNotificationCenter.current()
                        .removeDeliveredNotifications(withIdentifiers: [xxx])

它几乎可以工作,除了(这是一个主要问题)应用程序被用户刷出内存时。

有没有人找到删除通知的方法?

【问题讨论】:

    标签: ios swift apple-push-notifications ios10


    【解决方案1】:

    正如this SO answer 中提到的,我们必须发送另一个推送通知来清除之前发送的通知。

    该通知应包含badge:0,并省略alertsound 字段,然后它将从通知中心删除通知以及清除应用程序徽章。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-07
      • 1970-01-01
      • 2022-07-19
      • 2019-02-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多