应用程序在后台时未收到后台获取远程通知,并且用户未通过推送通知进入 [英] Not receiving background fetch remote notifications while application is backgrounded, and user does not enter through push notification

查看:54
本文介绍了应用程序在后台时未收到后台获取远程通知,并且用户未通过推送通知进入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序当前使用 application:didReceiveRemoteNotification:fetchCompletionHandlerapplication:didFinishLaunchingWithOptions: 委托方法来处理后台远程通知.间歇性地,将出现推送通知,并且我不会收到表明它已调用我的应用程序委托方法的日志.我已经对挂起、活动、后台和挂起状态进行了测试,它们似乎都可以正常工作.大约每 30 次推送中就有 1 次我收到死"推送通知.

My application currently uses the application:didReceiveRemoteNotification:fetchCompletionHandler and application:didFinishLaunchingWithOptions: delegate methods to handle background remote notifications. Intermittently, a push notification will appear, and I will not receive a log that says that it has called either of my application delegate methods. I have tested for suspended, active, background, and suspended states, and they all seem to be working correctly. About 1 in every 30 pushes I get a 'dead' push notification.

****注意:这种情况仅在我不通过触摸推送通知进入时才会发生,并且发生不可预测.**

****NOTE: This case only happens when I do NOT enter by touching the push notification, and happens unpredictably.**

推荐答案

该错误来自 Apple 文档中的 iOS 8功能".如果 iPhone 的蜂窝或 wifi 信号不佳、电池电量不足或未插入充电器,手机将在锁定屏幕上收到通知,但不会将应用启动到暂停状态.因此,如果您不通过滑动通知本身直接进入应用程序,则不会触发诸如 application:didReceiveRemoteNotification:fetchCompletionHandler 之类的后台事件.

The error came from an iOS 8 "feature" in Apple's docs. If an iPhone has less than great cellular or wifi signal, low battery, or is not plugged into a charger, the phone will receive the notification on the lock screen, but will not launch the app into a suspended state. Therefore, background events such as application:didReceiveRemoteNotification:fetchCompletionHandler will not be fired IF you do not enter directly into the application by swiping the notification itself.

这在测试中被一个事实所抵消,因为在调试过程中设备总是插入我的开发机器,并且有很强的 wifi 信号,所以我永远不会进入不良状态.

This was offset in testing by the fact that the device was always plugged into my development machine during debugging with a strong wifi signal, so I would never be put into a bad state.

这是非常具体的,但如果您的应用严重依赖于后台功能的推送通知,则这一点至关重要.

This is extremely specific, but crucial if your app relies heavily on push notifications for background functionality.

这篇关于应用程序在后台时未收到后台获取远程通知,并且用户未通过推送通知进入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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