Know if iOS notification was dismiss

时光总嘲笑我的痴心妄想 提交于 2019-12-20 02:31:41

问题


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?


回答1:


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.

  1. When you send a notification you keep information about it on server side.
  2. When you open the app from notification (that it's doable) you send information to a server side.
  3. When you open the app not from notification you can have a logic on a server side checking if there were any notification that were not confirmed from the last time you opened the application.

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.



来源:https://stackoverflow.com/questions/31929274/know-if-ios-notification-was-dismiss

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!