如何确定 iPhone 应用程序何时因推送通知而未打开?
据我所知,您可以捕获应用程序因推送通知而打开的事实。
- 应用程序不在后台 = didFinishLaunchingWithOptions 并评估“aps”的 launchOptions 应用
- 程序在后台 = didReceiveRemoteNotification 被调用
当然在 didFinishLaunchingWithOptions 中,我也可以通过没有“aps”的图标来区分正常打开应用程序
但是,如果应用程序是在后台并通过图标正常打开,我在哪里可以识别它?委托上没有调用特定的事件方法,我只得到 applicationWillEnterForeground ,无论哪种方式都可以调用它,而无需检查 launchOptions 。
我的场景是用户收到推送(更改徽章编号),关闭它(应用程序现在不知道),然后打开应用程序。徽章的变化告诉我,代替推开,应用程序外部发生了一些变化,需要某些行为。
谢谢 :)
I understand you can capture the fact that an app has opened due to a Push notification.
- App not in the background = didFinishLaunchingWithOptions and evaluate launchOptions for "aps"
- App in background = didReceiveRemoteNotification is called
Of course in didFinishLaunchingWithOptions I can also differentiate with opening the app normally via the icon by the absence of "aps"
However, if the app is in the background and is opened normally via the icon where can I identify this? There is no specific event method called on the delegate and I only get applicationWillEnterForeground which is called either way with no launchOptions to examine.
My scenario is the user gets a push (changing the badge number), closes it (app will not know about it now) and then later opens the app. The change in badge tells me in lieu of a push open that something has changed outside of the app requiring some behaviour.
Thx :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一番搜索后,我发现了一些关于检查应用程序状态的讨论。
http://www.nomadplanet.fr/2010/ 09/推送通知的不完整实现/
After some searching I found some discussion here about checking the application state.
http://www.nomadplanet.fr/2010/09/the-incomplete-implementation-of-push-notifications/