Can a local notification trigger code in iOS8?

时间秒杀一切 提交于 2019-12-02 12:24:35

问题


I am trying to create an app which will require more than 64 local notifications. Is there any way of triggering code when the system delivers a notification to the user without the user interacting with the notification?


回答1:


Yes and no.

If the notification is delivered when the app is in the foreground, it is delivered to you (the app), not to the user, so you will know in that way.

If is delivered when the app is not in the foreground, the app is not running so there is no one to tell. The app is not going to launch / wake you just to tell you that the notification took place. As you rightly imply, if the user asks the notification to contact you, you will be contacted, but otherwise, no.

However, you get an event when the app comes to the front once again, so you can always look to see whether the notification time happened "while you were out".

(Also note that the notification might never be delivered to the user. The user can just turn off notifications. It is risky to rely on them completely.)



来源:https://stackoverflow.com/questions/27585265/can-a-local-notification-trigger-code-in-ios8

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