知道iOS通知是否被解雇 [英] Know if iOS notification was dismiss
问题描述
有没有办法知道本地通知是否被通知中心解雇(例如按下x按钮)?
Is there any way to know if a local notification was dismiss from the Notification Center (for example by pressing the x button)?
是否可以获取通知中心当前可见的所有通知的列表?
Is it possible to get a list of all the notifications currently visible in the Notification Center?
推荐答案
不能从Apple的任何API获取通知列表。
并且没有来自忽略/关闭通知的反馈。
No it's not possible to get list of notifications from any of APIs from Apple. And no there is no feedback from ignored / closed notifications.
如果你想实现这样的逻辑,我建议建立这种类型的逻辑在您自己的服务器上。
If you want to implement logic like that, I would propose to build this type of logic based on your own servers.
- 当您发送通知时,您会在服务器端保留相关信息。
- 当您从通知中打开应用程序(它是可行的)时,您将信息发送到服务器端。
- 当您打开应用程序而非通知时,您可以在服务器端具有逻辑检查上次打开申请时是否有任何未通知的通知。
请注意,通知并非总是如此已交付 - 不保证用户将获得它们,如果使用已为您的应用程序启用通知 - 所有通知将被视为已忽略。
为了改善这种逻辑,您可能希望向服务器发送有关通知的用户权限的信息 - 这仍然不能保证他没有在设置中禁用它们:(
Keep in mind that notifications are not always delivered - it's not guarantee that user will get them and if use has notifications turned of for your application - all notifications will be treated as ignored. To improve that logic you may want to send information about user permissions for notifications to your servers - which still is not guarantee that he didn't disable them in settings :(
长话短说 - 永远不要根据通知构建任何应用程序核心功能。
Long story short - never ever build any of your application core functionality based on notifications.
这篇关于知道iOS通知是否被解雇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!