我们可以检测/识别用户是否明确地清除每个推送通知。
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
但是有没有办法当用户从通知中心托盘中一次清除所有推送通知时。
任何人的任何帮助都非常感谢。
我已经尝试为每个推送通知设置UNNotificationCategory,但仍然无法在
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
用于一次清除所有推送通知。
1条答案
按热度按时间lawou6xi1#
没有直接的方法来检测用户是否已经清除了所有通知。
但是你可以尝试如下的变通方法。
下面的函数给予已发送通知的计数。
你必须在你的应用程序中定期检查这个计数。如果计数变成零或者计数突然下降,那么用户很有可能已经清除了通知。
(请注意,这是一种变通方法。不是最佳实践)