iOS版 - 推内容 [英] iOS - Content of push

查看:225
本文介绍了iOS版 - 推内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我GOOGLE了很多,但我不能找到答案。

I googled a lot, but I can´t find the answer.

我试图得到一个推送通知的内容/载,而应用程序是在后台。

I'm trying to get the content / payload of a push notification while the app is in background.

方法:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

不起作用。

推荐答案

如果你没有任何后台模式应用程序(音频,GPS或VoIP 1 )的方法 - (无效)申请:(的UIApplication *)应用didReceiveRemoteNotification:(NSDictionary的*)USERINFO 将被调用不会立即但用户preSS后,打开按钮使应用前景。如果他或她决定跳过通知你无能为力,这意味着你需要刷新状态,当应用程序回到前台,你不能依靠推送通知来更新数据。

If you don't have any background mode for the application (one of audio, gps or voip) the method -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo will be called not instantly but after the user press "Open" button bringing the app to foreground. If he or she decides to skip the notification you can do nothing about it, meaning you need to refresh the state when the application is back to foreground, you can not rely on the push notifications to update the data.

更好的选择可能是使用徽章计数器来跟踪的变化,你需要计算它在服务器端。那么,如果在前台应用具有积极的证件号码你做更新数据并重置计数器。然而,这不是完美的,因为有没有保修通知交付 - 你仍然需要检查徽章柜台(或者你可以说,检查的更改次数)手动。

The better option might be to use the badge counter to track the changes, you need to calculate it on the server side. Then if the app in the foreground has the positive badge number you do update the data and reset the counter. However that's not perfect as there's no warranty the notification is delivered - you still need to check the badge counter (or you can say to check the number of changes) manually.

这篇关于iOS版 - 推内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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