我使用以下方法实现了推送通知的生成。
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
设备令牌通常会正确生成,但是当关闭声音和应用程序图标徽章并将警报样式设置为无(设置->应用程序名称->通知),设备令牌不生成。这个问题只出现在iOS 8设备上,在iOS 7设备上它能正常工作。请问有人能提供解决方案吗?