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

查看:80
本文介绍了未插入设备时未调用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中的错误,该错误已在7.1发布版本中修复,但可能没有任何问题可以与任何Beta,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分钟才能调用该方法,或者如果您在一个小时后推送相同的通知,则该方法可能会立即生效.也不确定.这确实很痛苦,但不要以为它会被修复,这就是苹果公司创建它的方式.

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发送了一个远程通知,直到第二天09.41h才调用didReceiveRemoteNotification:fetchCompletionHandler:.因此,就我而言,调用该方法花了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天全站免登陆