OGeek|极客世界-中国程序员成长平台

标题: ios - 通过从应用程序图标启动来处理应用程序完全关闭时的远程通知 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 08:53
标题: ios - 通过从应用程序图标启动来处理应用程序完全关闭时的远程通知

我可能会与风车搏斗,但我需要了解一下我对远程通知的了解。我想在我的应用程序关闭时处理通知(从应用程序切换器中杀死),但用户决定不是通过点击通知而是通过点击应用程序图标来打开它。

据我所知,当应用程序被杀死并且远程通知到达时,用户必须点击通知以在 didFinishLaunchingWithOptions:launchOptions 中传递它,但是......当用户点击应用程序图标并且没有任何内容传递给 lauchOptions 时,我想处理此通知。在那种情况下,目前我根本没有任何通知......

无论应用程序如何启动,是否可以在后台处理通知并对其执行操作?也许 didReceiveRemoteNotification: fetchCompletionHandler:



Best Answer-推荐答案


是的,你在和风车搏斗

我建议您阅读 Local and Push Notifications in depth .有点长,但是文档很清楚。

在此文档的片段中,您可以阅读:

If the application icon is tapped on a device running iOS, the application calls the same method (application:didFinishLaunchingWithOptions, but furnishes no information about the notification.

后来:

When handling remote notifications in application:didFinishLaunchingWithOptions: or applicationDidFinishLaunching:, the application delegate might perform a major additional task. Just after the application launches, the delegate should connect with its provider and fetch the waiting data. Listing 2-5 gives a schematic illustration of this procedure.

话虽如此,您可以为服务器中的每台设备提供已发送通知的列表,并且每次启动应用时检查设备是否有任何待处理的通知。

关于ios - 通过从应用程序图标启动来处理应用程序完全关闭时的远程通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22620952/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4