如何确定 iPhone 应用程序何时因推送通知而未打开?

发布于 2024-10-12 11:23:55 字数 474 浏览 2 评论 0原文

据我所知,您可以捕获应用程序因推送通知而打开的事实。

  • 应用程序不在后台 = 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桜花祭 2024-10-19 11:23:55

经过一番搜索后,我发现了一些关于检查应用程序状态的讨论。

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文