IOS8注册推送消息
2015-03-20 10:52
309 查看
IOS8在UIApplication文件中有说明:
- (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types
NS_DEPRECATED_IOS(3_0,
8_0,
"Please use registerForRemoteNotifications and registerUserNotificationSettings: instead");
// Returns the enabled types, also taking into account any systemwide settings; doesn't relate to connectivity.
- (UIRemoteNotificationType)enabledRemoteNotificationTypes
NS_DEPRECATED_IOS(3_0,
8_0,
"Please use -[UIApplication isRegisteredForRemoteNotifications], or -[UIApplication currentUserNotificationSettings] to retrieve user-enabled remote notification and user notification settings");
在IOS8下,采用了新的方法来注册推送和获取推送开启状态
注册推送的代码:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >=
8.0) {
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert
| UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else {
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
}
判断推送是否打开的代码:
+(BOOL)enabledRemoteNotification {
UIRemoteNotificationType types;
if ([[[UIDevice
currentDevice] systemVersion]
floatValue] >= 8.0) {
types = [[UIApplication
sharedApplication] currentUserNotificationSettings].types;
}
else {
types = [[UIApplication
sharedApplication] enabledRemoteNotificationTypes];
}
return (types &
UIRemoteNotificationTypeAlert);
}
- (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types
NS_DEPRECATED_IOS(3_0,
8_0,
"Please use registerForRemoteNotifications and registerUserNotificationSettings: instead");
// Returns the enabled types, also taking into account any systemwide settings; doesn't relate to connectivity.
- (UIRemoteNotificationType)enabledRemoteNotificationTypes
NS_DEPRECATED_IOS(3_0,
8_0,
"Please use -[UIApplication isRegisteredForRemoteNotifications], or -[UIApplication currentUserNotificationSettings] to retrieve user-enabled remote notification and user notification settings");
在IOS8下,采用了新的方法来注册推送和获取推送开启状态
注册推送的代码:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >=
8.0) {
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert
| UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else {
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
}
判断推送是否打开的代码:
+(BOOL)enabledRemoteNotification {
UIRemoteNotificationType types;
if ([[[UIDevice
currentDevice] systemVersion]
floatValue] >= 8.0) {
types = [[UIApplication
sharedApplication] currentUserNotificationSettings].types;
}
else {
types = [[UIApplication
sharedApplication] enabledRemoteNotificationTypes];
}
return (types &
UIRemoteNotificationTypeAlert);
}
相关文章推荐
- 【IOS】ios8推送消息注册
- iOS8推送消息、注册通知
- 【IOS】IOS8推送消息注册 通知
- 【IOS】ios8推送消息注册
- IOS开发之 ---- IOS8推送消息注册
- IOS开发之 ---- IOS8推送消息注册
- iOS8推送消息的快速回复处理
- iOS8注册推送
- iOS8推送消息的快速回复处理
- iOS注册远程推送消息证书后提示此证书签发者无效的解决办法
- Android高效率编码-第三方SDK详解系列(二)——Bmob后端云开发,实现登录注册,更改资料,修改密码,邮箱验证,上传,下载,推送消息,缩略图加载等功能
- xcode6开发ios8app应用程序,如何进行APNs推送消息(获取device token)和集成激光推送教程
- iOS注册远程推送消息证书后提示此证书签发者无效的解决办法
- IOS8 消息推送
- iOS8 推送注册方式改变的问题
- IOS8开发之实现App消息推送
- iOS注册远程推送消息证书后提示此证书签发者无效的解决办法
- iOS8 注册推送
- iOS8推送消息的快速回复处理
- iOS8推送消息的快速回复处理