用户在后台收到推送后手动打开应用程序时获取推送通知有效负载 [英] Getting push notification payload when user opens app manually after push has been received in the background

查看:69
本文介绍了用户在后台收到推送后手动打开应用程序时获取推送通知有效负载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS7,并且试图确定在以下情况下是否可以获取JSON有效负载.

I am using iOS7 and I am trying to determine if I can get the JSON payload in the following situation.

  • 我启用了后台模式远程通知"
  • 应用终止时收到推送通知
  • 该应用是通过通知中心中的图标手动启动的
  • I have background mode "remote-notifications" enabled
  • The push notification is received while the app is terminated
  • The app is launched manually from the icon not from the notification center

在收到通知后,我从图标本身启动应用程序时,我没有收到来自启动选项的推送

When I launch the app from the icon itself after the notification has been received I do not get the push in the launch options from

<代码>-(BOOL)应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;

并且当通过图标手动启动应用程序时,以下方法也不会被调用

and the following method does not get called either when app is manually launched from the icon

<代码>-(void)应用程序:(UIApplication *)应用程序didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void(^)(UIBackgroundFetchResult))completionHandler {

推荐答案

我终于弄清楚了如何获得它!

I finally figured out how you can get this!

从iOS 7开始,您可以获取它!

As of iOS 7 you can get it!

基本上,您需要为后台远程通知配置应用程序.

Basically, you need to configure your application for background remote notifications.

因此,在您的info.plist文件中:所需背景-将其设置为 app从推送通知中下载内容.

So, in your info.plist file: For required backgrounds - set it to app downloads content from push notifications.

AppDelegate.m 文件中,您需要实现此方法:

In the AppDelegate.m file, you need to implement this method:

-(void)应用程序:(UIApplication *)应用程序didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void(^)(UIBackgroundFetchResult))completionHandler

有关如何实现该功能的信息,请参见以下内容: didReceiveRemoteNotification:fetchCompletionHandler:打开从图标vs推送通知中

See this for how to implement that: didReceiveRemoteNotification: fetchCompletionHandler: open from icon vs push notification

对于推送通知,您必须具有'content-available':1,作为推送通知的一部分.这就是在显示警报之前告诉应用程序有新内容的原因.

For your push notifications, you must have 'content-available': 1, as part of the push notification. This is what tells the application that there is new content before displaying the alert.

有关此后台远程通知的更多信息,请参见此页面: http://developer.xamarin.com/guides/cross-platform/application_fundamentals/backgrounding/part_3_ios_backgrounding_techniques/updating_an_application_in_the_background/

See this page for more information on background remote notifications: http://developer.xamarin.com/guides/cross-platform/application_fundamentals/backgrounding/part_3_ios_backgrounding_techniques/updating_an_application_in_the_background/

这篇关于用户在后台收到推送后手动打开应用程序时获取推送通知有效负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆