ios - 通过从应用程序图标启动,在应用程序完全关闭时处理远程通知

标签 ios iphone objective-c notifications appdelegate

我可能会与风车作斗争,但我需要对我的远程通知知识进行一些清理。我想在我的应用程序关闭(从应用程序切换器中终止)时处理通知,但用户决定不是通过点击通知而是通过点击应用程序图标来打开它。

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

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

最佳答案

是的,你正在与风车战斗:)

我建议您阅读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/

相关文章:

ios - 带 Images.xcassets 的 SplashScreen 在模拟器上工作,但在 iPad 上黑屏

html - Swift : Displaying HTML data in a label using NSAttributedString. DocumentType.html 慢

iphone - Obj-C 在 substringWithRange 消息上崩溃

iphone - 如何使用 iphone sdk 比较两个图像?

iphone - 整个文件不可用时 MPMoviePlayerViewController 的通知?

iphone - 在自定义 UITableViewCell 中管理 UITextFields 的委托(delegate)

iphone - 核心数据获取不一致

ios - 添加ui进度 View ios

ios - 游戏中心沙盒模式显示多个排行榜

iphone - 如何保存已经用NSUserDefaults添加的subView?