Push Notification代理调用回调没有被调用 [英] Push Notification delegate call backs are not getting called

查看:266
本文介绍了Push Notification代理调用回调没有被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过调用以下代码注册推送通知:

I am registering for Push Notification by calling the following piece of code:

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound];

但在一些罕见的情况下,委托不会被调用:

But in some rare cases following delegate does not get called:

- (void)application:(UIApplication *)iApplication didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)iNewDeviceToken {

甚至没有调用以下方法:

Not even following method gets called:

- (void)application:(UIApplication *)iApplication didFailToRegisterForRemoteNotificationsWithError:(NSError *)iError {

可能是什么原因。一旦我收到设备令牌,我就会继续执行我的应用流程。

What could be the reason for this. I am proceeding with my app flow once I received the device token. So, in some rare scenarios my app hungs.

推荐答案

根据文档,在设备与推送服务器持续连接之前,都不会发生回调。因此,如果没有WiFi或数据连接可用,回调不会发生 - 苹果不认为这是一个错误条件。据我所知,可能发生的唯一错误导致didFail ...回调是一个不正确的证书/应用程序权限问题(一个开发问题),或用户拒绝的权限(虽然我只是偶尔能够重现这个通过更改日期并关闭手机)。

According to the documentation, neither of the callbacks will happen until the device has a persistent connection with the push server. So if there is no wifi or data connection available, the callbacks won't happen - and apple doesn't regard this as an error condition. As far as I can tell, the only errors that can happen to cause the didFail... callback are an incorrect certificate/app permissions issue (a development problem), or the user declined permission (though I am only sporadically able to reproduce this by changing the date and turning the phone off).

这篇关于Push Notification代理调用回调没有被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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