didRegisterForRemoteNotificationsWithDeviceToken从来没有所谓的特定设备上 [英] didRegisterForRemoteNotificationsWithDeviceToken never called on specific device

查看:197
本文介绍了didRegisterForRemoteNotificationsWithDeviceToken从来没有所谓的特定设备上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我对iPhone 6加/ iOS的8.1和我已经在这里尝试了一切:<一href=\"http://stackoverflow.com/questions/4086599/why-didregisterforremotenotificationswithdevicetoken-is-not-called\">why didRegisterForRemoteNotificationsWithDeviceToken不叫

First of all, I am on iPhone 6 Plus/iOS 8.1 and I've tried everything here: why didRegisterForRemoteNotificationsWithDeviceToken is not called

还是无济于事。总结:


  • 我检查我的包标识符匹配置备一个配置文件/开发门户

  • 我创建了一个新的发展推APNS证书

  • 我创建了一个新的发展证书

  • 我创建为发展证明了新的供应配置文件

  • 我已经下载证书和供应的空间,显然,双点击它们安装

  • 我已经验证这一切是正确的开发者门户网站:所有的证书和配置配置文件有效,推启用并与我的新APNS证书配置

  • 我上传我的新APNS证书解析(这是无关紧要的这一步,但无论如何)作为我使用解析为我的后端

  • 我确信,我使用了正确的证书/在X code至codesign
  • 供应轮廓对
  • 我检查的情况下,我的应用程序不允许接收推送通知的设置,它不存在

  • 我已经试过手动设置日期明天尝试重新安装应用程序

  • 我已经从我的设备中删除应用程序

  • 我已经从我的设备中删除任何相关的资源调配配置文件

  • 我重新启动我的设备多次

的application:didFinishLaunchingWithOptions:我称之为:

if([application respondsToSelector:@selector(registerUserNotificationSettings:)]){
        //iOS 8+
        [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    }else{
        //pre-iOS 8
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
         (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
    }

应用程序:didRegisterUserNotificationSettings:我称之为:

[application registerForRemoteNotifications];

我和断点检查了它,它不会被调用。我也实现了两个方法:

I've checked it with a breakpoint, it DOES get called. I've also implemented two methods:

应用程序:didRegisterForRemoteNotificationsWithDeviceToken:

应用程序:didFailToRegisterForRemoteNotificationsWithError:

然而,它们都不被调用。不是一个错误,没有什么。在控制台没有错误无论是。 (我已经有大约权益的问题今天早些时候,但创建新的证书/配置简介解决了)

However, neither of them is called. Not an error, nothing. No error at the console either. (I've had an issue about entitlements earlier today, but creating new certificate/provisioning profile solved that)

这可能是什么问题?

更新:这是后话。在应用程序:didRegisterUserNotificationSettings:我检查的通知设置,这里是什么我有:

UPDATE: Here is something. In application:didRegisterUserNotificationSettings: I've checked the notification settings and here is what I've got:

(lldb) po notificationSettings
<UIUserNotificationSettings: 0x170031cc0; types: (none);>

更新2:我检查的通知又来了,发现了,现在我的应用程序被添加到设置的通知,它的启用,给予许可。但尽管如此,该处理程序不被调用。
类型没有。我敢肯定,99%的它的相关的问题。

UPDATE 2: I've checked notifications again, and found out that now my app is added to the notifications in Settings, it's enabled, given permissions. But still, the handler is not called. Types are none. I'm 99% sure it's related to the problem.

更新3:我另一个设备(iPod touch的iOS版8.1)上测试,和我有没有问题存在。它马上叫应用程序:didRegisterForRemoteNotificationsWithDeviceToken:方法与令牌。问题是具体到我的iPhone。

UPDATE 3: I've tested on another device (iPod touch, iOS 8.1), and I've got no problems there. It immediately called the application:didRegisterForRemoteNotificationsWithDeviceToken: method with its token. The problem is specific to my iPhone.

推荐答案

有人问我调试的类似行为上的客户端应用程序,iOS9下。

I was asked to debug similar behaviour on a clients app, under iOS9.

原来的应用程序从调用的appDelegate和registerUserNotificationSettings作为registerForRemoteNotifications常见。

It turns out the app was calling registerUserNotificationSettings and registerForRemoteNotifications from the appDelegate as is common.

然而,也有人此后不久做第二次在后续permissionsViewController。

However, it was also doing this a second time shortly after in a subsequent permissionsViewController.

如果用户拒绝从的appDelegate所得则后续尝试以允许通知的请求的用户所看到的理由,用于允许它(从permissionsViewController第二呼叫)分别设置与设置为零类型相同的appDelegate呼叫后

If a user declined the request resulting from the appDelegate then the subsequent attempts to allow notifications after a user had seen a rationale for allowing it (the second calls from the permissionsViewController) were set with types set to zero same as the appDelegate calls.

删除最初的appDelegate电话和仅具有permissionsViewController调用present解决了这个。

Removing the initial appDelegate calls and having only the permissionsViewController calls present solved this.

这篇关于didRegisterForRemoteNotificationsWithDeviceToken从来没有所谓的特定设备上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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