ios (推送之远程推送)升级成ios8系统之后有些程序接收不到远程推送
来源:程序员人生 发布时间:2015-02-03 08:45:54 阅读次数:3236次
保护1个程序,当手机升级到ios8以后就不能接收到远程推送,显示注册失败,查了下资料,原来是没有获得用户许可,加了个方法试了下,ok
if ([[[UIDevice currentDevice]systemVersion ]integerValue] >= 8) {
UIUserNotificationSettings*setting = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil];
[application registerUserNotificationSettings:setting];
[application registerForRemoteNotifications];
}else{
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound];
}
系统版本不同所用的注册方法也是不1样的,下面是苹果sdk给出的说明:
- (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types NS_DEPRECATED_IOS(3_0, 8_0, <span style="color:#FF0000;">"Please use registerForRemoteNotifications and registerUserNotificationSettings: instead"</span>);
生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠