ユーザーがプッシュ通知を読んだ後、通知センターからプッシュ通知をクリアする必要があります。cancelAllLocalNotifications メソッドがあることは知っていますが、すべてのリモート通知をクリアするにはどうすればよいですか? さらに、次の機能が必要です。ユーザーが通知センターに 5 つのメッセージを持っている場合、ユーザーがすべてを読んだ後にのみすべての通知をクリアします。これらをどのように実装できるかについてのアイデアはありますか? 助けてくれてありがとう。
2117 次
2 に答える
5
通知を素早くクリアしたい場合
import UserNotifications
if #available(iOS 10.0, *) {
let center = UNUserNotificationCenter.current()
center.removeAllPendingNotificationRequests() // To remove all pending notifications which are not delivered yet but scheduled.
center.removeAllDeliveredNotifications() // To remove all delivered notifications
}
于 2017-01-11T06:45:07.083 に答える
1
を使用してそれらをクリアできますsetApplicationIconBadgeNumber
。例:
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
于 2013-03-07T16:32:06.473 に答える