ios - 当我的应用程序处于后台时,只有当我触摸顶部通知横幅时才会处理推送通知

标签 ios push-notification

我已经实现了

application:didReceiveRemoteNotification:

在收到推送通知时将数据存储在我的应用中。

然而,当我的应用程序在后台并且我收到通知时,只有当我触摸出现在顶部的通知横幅时才会存储数据:

enter image description here

相反,如果我触摸应用程序图标将其重新打开,则不会存储通知的内容:

enter image description here

因为我只在使用分发配置文件时收到通知,所以我不确定 application:didReceiveRemoteNotification: 是否仅在我将通知横幅推到顶部时被调用。

我认为它总是在收到通知时调用,而不是在设备上的用户操作之后调用。

更新。 我不知道这是否有帮助,但只是想让你知道,我还没有实现任何这些方法:

– applicationDidEnterBackground:
– applicationWillEnterForeground:
- applicationDidBecomeActive:

最佳答案

我想我已经找到原因了。来自文档:

If the action button is tapped (on a device running iOS), the system launches the application and the application calls its delegate’s application:didFinishLaunchingWithOptions: method (if implemented); it passes in the notification payload (for remote notifications) or the local-notification object (for local notifications).

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

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html

但是,我想知道是否有一种方法可以加载负载,即使应用程序已通过触摸图标重新打开。

关于ios - 当我的应用程序处于后台时,只有当我触摸顶部通知横幅时才会处理推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11602826/

相关文章:

iphone - 如何从外部框架加载资源

c# - MonoTouch File.ReadAllText 在内部 FileStream.Dispose() 上抛出异常

ios - 如何在 UIImageView 中以编程方式使 UIButton 居中?

java - 如何设置 javapns(iOS 推送通知)?

android - PunNub - 设备关闭时恢复丢失消息的最佳方法?

ios - Objective c 用于内存管理的ARC AC 算法,这是垃圾收集吗?

iOS:将名称存储在 plist 中

ios - 如何知道应用程序何时收到通知以及用户何时在 iOS 中单击通知

ios - 应用程序收到推送通知时的操作

android - 当应用程序关闭或应用程序处于后台时获得两次 GCM PUSH 通知