简体   繁体   English

registerForRemoteNotifications在iOS9上有效,在iOS8上失败

[英]registerForRemoteNotifications works on iOS9, fails on iOS8

For the user to allow badge / sound / alert and to get the notification token, I use the simple and classic code (for iOS >= 8) in the application:didFinishLaunchingWithOptions: 为了允许用户使用徽章/声音/警报并获取通知令牌,我在application:didFinishLaunchingWithOptions:使用了简单经典的代码(对于iOS> = 8) application:didFinishLaunchingWithOptions:

UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];

After calling this code on an iOS9 device, the didRegisterForRemoteNotificationsWithDeviceToken: callback is called and I get my token. 在iOS9设备上调用此代码后, didRegisterForRemoteNotificationsWithDeviceToken:回调被调用,我得到了我的令牌。

But running the exact same code, same bundleId, on an iOS8 device gives me an error (through the didFailToRegisterForRemoteNotificationsWithError: callback). 但是在iOS8设备上运行完全相同的代码,相同的bundleId会给我一个错误(通过didFailToRegisterForRemoteNotificationsWithError:回调)。

The error is the "no valid 'aps-environment' entitlement string found for application", which doesn't make sense in this case because it's working fine on iOS9! 错误是“找不到适用于应用程序的有效'aps-environment'授权字符串”,在这种情况下没有意义,因为它在iOS9上运行良好!

仅在通过Xcode在设备上部署应用程序时才发生此问题,当使用企业证书部署OTA时,它按预期工作:/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM