以前做远程推送通知,知道远程推送通知在IOS8下有新的变化
变化如下:(关于远程推送,大家可以去下载我的资源----> <<IOS远侧推送手册>> 以及在不同环境下的测试资源,充分为大家考虑。在这里就不再赘述了!)
//注册远程推送通知
if ([[[UIDevice currentDevice]systemVersion]floatValue]>=8.0) {
//ios8下注册远程推送通知
[[UIApplication sharedApplication]registerForRemoteNotifications];
UIUserNotificationType types = UIUserNotificationTypeBadge|UIUserNotificationTypeSound ;
UIUserNotificationSettings * setting = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:setting];
}else{
//ios8以前的版本环境下注册远程推送通知
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: UIRemoteNotificationTypeBadge|UIUserNotificationTypeSound];
}
NSDictionary *remoteNotifiInfo = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
//Accept push notification when app is not open
if (remoteNotifiInfo) {
[self application:application didReceiveRemoteNotification:remoteNotifiInfo];
}
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)])
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
}