iOS8 兼容 请求开启远程推送代码
2015-04-10 11:19
204 查看
//register for push notification if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8) { [[UIApplication sharedApplication] registerForRemoteNotifications]; UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert ; UIUserNotificationSettings * setting = [UIUserNotificationSettings settingsForTypes:types categories:nil]; [[UIApplication sharedApplication] registerUserNotificationSettings:setting]; NSLog(@"isIOS8"); } else { [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)]; NSLog(@"not isIOS8"); } BOOL bPushEnable = NO; if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8) { UIUserNotificationSettings * pushSetting = [[UIApplication sharedApplication] currentUserNotificationSettings]; if (pushSetting) { UIUserNotificationType pushType = pushSetting.types; NSLog(@"push type = %d", pushType); if (pushType == UIUserNotificationTypeNone) { bPushEnable = NO; } else { bPushEnable = YES; } } } else { UIRemoteNotificationType pushType = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; NSLog(@"push type = %d", pushType); if (pushType == UIRemoteNotificationTypeNone) { bPushEnable = NO; } else { bPushEnable = YES; } } //如果不能推送 if (bPushEnable == NO) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[UtilsHelper getLocalizeString:@"text_push_notification_title"] message:[UtilsHelper getLocalizeString:@"text_push_notification_content"] delegate:self cancelButtonTitle:[UtilsHelper getLocalizeString:@"text_yes"] otherButtonTitles:nil, nil]; [alert show]; }
相关文章推荐
- iOS8 兼容 请求开启远程推送代码
- iOS8 开启定位兼容代码
- iOS8之后的远程推送注册代码
- ios8 远程推送的注册代码
- ios8 sdk 推送兼容代码 registerForRemoteNotifications
- Git 将本地代码推送到新建远程项目的 GIT 仓库中
- ios (推送之远程推送)升级成ios8系统之后有些程序接收不到远程推送
- IE浏览器兼容模式自动开启代码
- ios8以上远程推送 demo
- ios8下的远程推送通知
- IOS8 兼容本地推送
- 远程通知推送(带java端后台代码)
- 远程通知推送后台代码( PHP 和 java )
- 食智已经实现的远程推送代码
- 代码开启sql2005远程连接功能
- ios远程通知,兼容ios7 ios8
- 利用个推做测试远程推送的证书生成代码
- IOS 推送机制详解,兼容IOS8的推送
- 在iOS8之后的远程推送写法
- 远程桌面服务授权不能处理您的请求。错误代码是 800。