iOS的UIBackgroundMode远程通知不上4G工作 [英] iOS UIBackgroundMode remote-notification doesn't work on 4G

查看:314
本文介绍了iOS的UIBackgroundMode远程通知不上4G工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试推送通知与内容可用= 1,他们似乎并不在后台交付给应用程序,除非使用Wi-Fi。

I'm testing push notifications with content-available=1, and they don't seem to be delivered to the app in the background unless on Wi-Fi.

我在推通知处理程序的开始一个简单的日志语句:

I have a simple log statement at the beginning of the push notification handler:

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

    NSLog(@"Notification received: %@", userInfo);
    completionHandler(UIBackgroundFetchResultNewData);
}

下面是我的测试:


  1. 运行应用程序,那么preSS home键放在后台的应用程序。

  2. 发送推送通知与内容可用= 1

  3. 手表控制台日志

在无线网络连接,控制台日志显示通知。如果我去设置和关闭无线网络连接,切换到4G,通知不再出现在日志中(尽管它们在屏幕的上方滑动,所以我知道他们正在被送到)。

On Wi-Fi, the console log shows the notification. If I go to Settings and turn off Wi-Fi, switching to 4G, notifications no longer appear in the log (although they do slide in at the top of the screen, so I know they are being delivered).

有没有崩溃的日志记录,如果我手动点击其上的通知记录。此外,如果我在调试X code中的应用程序不会出现此问题。 (即,如果我以x code调试我的应用程序将获得4G的后台通知)。任何人都经历这种行为?还是我做错了什么?

There are no crash logs, and the notification is logged if I manually tap on it. Furthermore, this problem does NOT occur if I am debugging the app in Xcode. (i.e., if I am debugging in Xcode, the app will receive the notification in the background on 4G). Has anyone else experienced this behavior? Or am I doing something wrong?

修改
具体而言:根据我的测试,如果下列条件为真,那么远程通知委托上述方法将不会被调用:

EDIT: To be specific: according to my tests, if the following conditions are true, then the remote notification delegate method above will not be called:


  1. 应用程序在后台运行

  2. Phone是LTE网络,没有连接到Wi-Fi

  3. 应用是不是在X code调试运行

  4. 的通知与内容可用= 1是通过手机收到

不过,如果条件2被删除(即手机连接到Wi-Fi),则该处理器将被调用。

However if condition 2 is removed (i.e., the phone is connected to Wi-Fi), then the handler will be called.

推荐答案

根据从这里评论者的反馈和多个设备上反复试验,这似乎是在iOS上的错误(或预期的行为)。

Based on feedback from a commenter here and repeated testing on multiple devices, this appears to be a bug (or intended behavior) on iOS.

这篇关于iOS的UIBackgroundMode远程通知不上4G工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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