[英]iOS remote push notification with app background
Looking on web and in many stackoverflow post i have seen that the only way to get remote push notification when the app is in background (and it is launched from icon and not from push message) is to call the server when the app is loaded and get the "last" messages. 在网络上和许多stackoverflow帖子中,我已经看到,当应用程序在后台运行时(从图标而不是从推送消息启动),获取远程推送通知的唯一方法是在加载应用程序时调用服务器并得到“最后”消息。
I've made this test with instant messaging app (i dont tell the name of the app, but i think you understand): 我已经使用即时通讯应用程序进行了此测试(我不告诉应用程序名称,但我认为您可以理解):
So, if i'm in foreground, i can handle the notification on method didReceiveRemoteNotification. 因此,如果我处于前台,则可以处理关于didReceiveRemoteNotification方法的通知。
If the app is in background i can handle the nofification in didFinishLaunchingWithOptions (if i launch it with push notification pop-up). 如果应用程序在后台运行,我可以在didFinishLaunchingWithOptions中处理命名(如果我使用推送通知弹出窗口启动它)。
How it's possible to handle the notification when the application is in background and it is launched from icon and not from the push pop-Up? 当应用程序处于后台并且从图标而不是从推送弹出窗口启动时,如何处理通知?
Thanks 谢谢
(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { (void)应用程序:(UIApplication *)应用程序didReceiveRemoteNotification:(NSDictionary *)userInfo {
UIApplicationState state = [application applicationState]; UIApplicationState状态= [应用程序applicationState];
if (state == UIApplicationStateActive) { // write code here for handle push notification when app is in foreground } else { // write code here for handle push notification when app is in background } } if(state == UIApplicationStateActive){//在应用程序处于前台状态时在此处编写处理推送通知的代码} else {//在应用程序处于后台状态时用于编写处理推送通知的代码}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.