我已经实现了
application:didReceiveRemoteNotification:
在收到推送通知时将数据存储在我的应用中。
然而,当我的应用程序在后台并且我收到通知时,只有当我触摸出现在顶部的通知横幅时才会存储数据:
相反,如果我触摸应用程序图标将其重新打开,则不会存储通知的内容:
因为我只在使用分发配置文件时收到通知,所以我不确定 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.
但是,我想知道是否有一种方法可以加载负载,即使应用程序已通过触摸图标重新打开。
关于ios - 当我的应用程序处于后台时,只有当我触摸顶部通知横幅时才会处理推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11602826/