我将我的 Xcode 升级到 Xcode 6.0.1,现在 iOS 8 设备不会发生远程通知注册。它适用于 iOS 7 设备。
我已经在 app delegate 中添加了如下所述的代码:
//-- Set Notification
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge
|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
NSLog(@"current notifications : %@", [[UIApplication sharedApplication] currentUserNotificationSettings]);
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
即使当前通知存在,也不是零。
但是下面的方法没有被调用:
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
下面的屏幕截图解释了我在后台模式下启用了某些选项:
通知是在我的应用的设备设置中设置的。
最佳答案
你需要打电话
[[UIApplication sharedApplication] registerForRemoteNotifications];
在您的 iOS8 代码路径中,在注册用户通知设置之后。
关于objective-c - 为什么应用程序没有在 iOS 8 中注册推送通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26053220/