手机升级到ios8.0以后,发现之前能用的消息推送不能用了,提示”registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later”.查了下资料,原来ios8.0修改了消息通知的注册方式.
修改成交互式的推送了,即在消息中心就可以回复了,不用再进入app.
注册方式:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings
settingsForTypes:(UIUserNotificationTypeSound |
UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge)
categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else {
[[UIApplication sharedApplication]registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|
UIRemoteNotificationTypeBadge|
UIRemoteNotificationTypeSound];
}
同理判断消息推送是否打开也有变化
UIRemoteNotificationType types;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
types = [[UIApplication sharedApplication] currentUserNotificationSettings].types;
else
types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
return (types & UIRemoteNotificationTypeAlert);