未插入设备时未调用 iOS8.1.2 didReceiveRemoteNotification 方法 [英] iOS8.1.2 didReceiveRemoteNotification method not called when device is not plugged in

查看:13
本文介绍了未插入设备时未调用 iOS8.1.2 didReceiveRemoteNotification 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 iOS 8.1.2 版本中,我发现了一个很奇怪的问题:
我实现了下面的方法来处理 appDelegate 中的推送信息

In iOS version is 8.1.2,I found a really strange issue:
I implement below method to handle push info in appDelegate

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

如果您的设备未插入,则不会调用此方法.

If your device is not plugged in,this method is not called.

推荐答案

如果你环顾四周,你会发现其他人认为这是 iOS 7.1 beta 中的一个 bug,在 7.1 发布版本中修复,但它可能什么都没有与任何测试版、Testflight、特定的 8.1.2 版本等有关,就像您在回答中所说的那样.我很确定这个是唯一正确的答案.顺便说一句,我有同样的问题,但在 8.1.3 中,所以我想它也会与您一起出现.

If you look around, you'll see that others thought it would be a bug in iOS 7.1 beta, fixed in 7.1 release version, but it has probably nothing to do with any beta, Testflight, specific 8.1.2 version etc, like you say in your answer. I'm pretty sure this is the only correct answer. By the way, I have the same issue, but in 8.1.3, so I guess it will reappear with you too.

删除应用程序后,重新启动手机并安装应用程序,didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler: 被调用得很好(这解释了使用 tesflight!",在 7.1.x 中它有效!"等),但是如果由于接收到远程通知或未按时调用完成处理程序而进行了过多的计算,系统将不再喜欢您并在稍后开始调用该方法它想要,通常会在收到您的通知后 0-30 分钟,或者很长(请参阅下面的更新).对我来说,有时在第一次远程通知之后就已经发生了.当然,除非设备已插入,否则它会更加可靠.

Once you delete the app, restart your phone, and install the app, the didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler: is called perfectly fine (which explains the "Use tesflight!", "in 7.1.x it works!", etc), but if you do too much calculations as a result of receiving the remote notification or not calling the completion handler on time, the system will not like you anymore and start calling the method later when it wants to, which will generally be 0-30 minutes after your notification has been received, or veeery long (see update below). With me, sometimes that happened already after the first remote notification. Unless, of course, the device is plugged in, then it will be much more reliable.

一旦您重新连接(插入)设备,系统可能会调用您的方法,通常最多需要 15 分钟才能调用它,或者如果您在一小时后推送相同的通知,它可能会立即起作用,但是也不确定.这真的很痛苦,但不要认为它会被修复,这就是 Apple 创建它的方式.

Once you reconnect (plug in) the device, the system might then call your method, generally it takes up to 15 minutes before it gets called, or it might just work instantly if you push the same notification an hour later but that also is not sure. It's really a pain, but don't think about it as something that will be fixed or so, it's the way Apple created it.

更新:它最终会被调用.我在 18.13h 发送了一个远程通知,并且 didReceiveRemoteNotification:fetchCompletionHandler: 直到第二天 09.41h 才被调用.所以就我而言,调用该方法需要 15.5 个小时.就我而言,这样做的原因可能是我使用远程通知在后台启动和停止位置跟踪,这很麻烦.

UPDATE: It will be called eventually. I sent a remote notification at 18.13h, and didReceiveRemoteNotification:fetchCompletionHandler: was not called until 09.41h the next day. So in my case, it took 15.5 hours until the method was called. In my case, the reason for that is probably that I use remote notifications to start and stop location tracking in the background, which is heavy stuff.

这篇关于未插入设备时未调用 iOS8.1.2 didReceiveRemoteNotification 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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