美文网首页iOS
推送之didReceiveRemoteNotification

推送之didReceiveRemoteNotification

作者: survivorsfyh | 来源:发表于2017-12-12 16:43 被阅读27次

今天在调试时候,发现控制台打印如下的日志警告,如下图:

-[<UIApplicationDelegate>  application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.


大致意思理解为在 ApplicationDelegate 中我们实现了 

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

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

 以上方法,但是未在 plist 文件中添加 Background Modes 的模式,所以会出现如上日志警告.


该日志内容是用来提示开发者若要支持后台模式,则需要开启远程通知;

具体原因可查看官方文档说明: iOS 7 Background Remote Notification

大致意思个人理解为:

"Silent Remote Notifications"增加了一定频率的控制限制,如此一来会受到频率过高的发送推送消息,其推送的内容并不会所有的都能按照预期到达客户端触发函数的影响;

"Background"下提供给应用的运行时间窗是有限制的,若要下载较大的文件需参考 Apple 的 NSURLSession 介绍;

"Background Remote Notification"使用后台远程推送功能则首先需要客户端满足当前状态处于挂起模式或后台悬浮模式的前提条件.

注:若用户通过任务管理器将当前应用直接从后台杀掉则将不会在唤醒应用处理 Background 下的代码逻辑.


解决办法:

将 projects -> Capabilities -> Background Modes 这项设置为"ON";

勾选中该列表中 Background fetch 和 Remote notifications 两项即可.

相关文章

网友评论

    本文标题:推送之didReceiveRemoteNotification

    本文链接:https://www.haomeiwen.com/subject/badnixtx.html