无法获取设备 运行 iOS 8+ (APNS) 的设备令牌

Could not get Device Token for Device running iOS 8+ (APNS)

我正在开发一个 iOS 应用程序,部署目标为 iOS 8。不知何故,我 没有 委托回调 对于 application:didRegisterForRemoteNotificationWithDeviceTokenapplication:didFailToRegisterForRemoteNotificationWithError。 虽然在模拟器中 运行 会调用 application:didFailToRegisterForRemoteNotificationWithError(,这是预期的 ),但在设备上时,两种方法都不会被调用。

在application:DidFinishLaunchingWithOptions中编写的用于注册APNS的代码:

let notificationType = UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound
let notificationSetting = UIUserNotificationSettings(forTypes: notificationType, categories: nil)

UIApplication.sharedApplication().registerUserNotificationSettings(notificationSetting) 
UIApplication.sharedApplication().registerForRemoteNotifications()

关于证书,我的生产和开发证书似乎都很好。按照会员中心中提到的相同步骤创建,APP ID 还在 Push Notification[=] 上显示 Green Dots 33=] Dev 和 Distribution 字段。此外,创建的生产证书似乎有效。

我重新创建了证书,检查了 BundleId,从 KeyChain 中删除了旧证书,用新证书替换了它们。 此外,删除设备上现有的配置文件(使用 xCode)只是为了确保设备上以前的配置文件会产生干扰。但是没有成功

无法真正弄清楚可能是什么问题。但是,我几次成功地将远程通知发送到设备。

apns 沙箱今天似乎宕机了。它使用代码 200 响应推送通知,但不会将推送通知传送到设备。

请注意 https://developer.apple.com/system-status/ 没有显示任何异常,可能是因为沙箱监控的优先级不是很高。