问题
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.
- When you send a notification you keep information about it on server side.
- When you open the app from notification (that it's doable) you send information to a server side.
- 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