仅当应用程序在后台时才调用静默通知回调方法 [英] Silent notification callback method called only when app is in background

查看:28
本文介绍了仅当应用程序在后台时才调用静默通知回调方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注册了远程通知并且它工作得很好.现在我正在实施静默通知.为此,我启用了后台远程通知和应用程序从网络下载内容.

I registered remote notification and its working absolutely fine. Now I am implementing silent notification. For that, I enabled background remote notification and App downloads content from the network.

和发送,

{"aps": {"content-available": 1}}

它调用下面的回调方法,但仅当应用程序在后台时:

its calling the below callback method but only when app is in background:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler

在这种方法中,我在从服务器下载一些数据后触发本地通知.但是当应用程序不在后台时,此方法根本不会调用.

And in this method, I am firing local notification after downloading some data from the server. But this method doesn't call at all when app is not in background.

在关于 推送通知,他们在说:

当无提示通知到达时,iOS 在后台唤醒您的应用,以便您可以从服务器获取新数据或进行后台信息处理."

"When a silent notification arrives, iOS wakes up your app in the background so that you can get new data from your server or do background information processing."

理想情况下,静默远程通知应该在后台唤醒我的应用,并且本地通知应该可以工作.

Ideally, silent remote notification should wake up my app in background and the local notification should work.

有什么想法吗?

推荐答案

经过大量的苹果文档阅读,我发现如果用户强制退出应用程序,方法 (didReceiveRemoteNotification: fetchCompletionHandler) 将不会调用.

After lot of apple docs reading, I found that the method (didReceiveRemoteNotification: fetchCompletionHandler) will not invoke if user has force-quit the app.

如所写,(link)但是,如果用户强制退出,系统不会自动启动您的应用程序.在这种情况下,用户必须重新启动您的应用或重新启动设备,然后系统才会再次尝试自动启动您的应用.

As written, (link) However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.

这篇关于仅当应用程序在后台时才调用静默通知回调方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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