Objective-C获取应用是否允许消息通知的方法
2016-01-05 14:27
465 查看
用户可能对应用设置是否允许通知,OC的API中iOS8之前和之后是两个方法:
- (BOOL)isAllowedNotification {
if ([[UIDevice currentDevice].systemVersion doubleValue] < 8.0) {
UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if(UIRemoteNotificationTypeNone != type)
return YES;
}else{
UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
if (UIUserNotificationTypeNone != setting.types) {
return YES;
}
}
return NO;
}
- (BOOL)isAllowedNotification {
if ([[UIDevice currentDevice].systemVersion doubleValue] < 8.0) {
UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if(UIRemoteNotificationTypeNone != type)
return YES;
}else{
UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
if (UIUserNotificationTypeNone != setting.types) {
return YES;
}
}
return NO;
}
相关文章推荐
- Objective C运行时(runtime)技术的几个要点总结
- Objective-C汉字转换成拼音的方法
- Objective-C语法概述
- Objective-C语法概述
- hbuider 中点击就显示出一个单选的列表 ,然后后台跨域向里面动态添加数据,注意里面的格式是json object
- Photos(PHObject)
- Objective-C之内存管理
- Objective-C利用AFN实现图片下载,支持断点续传,显示下载进度
- setObjectForKey和setValueForKey的用法和区别
- Jsp中request.getParameter("@param")值为[object HTMLInputElement]
- 通知中心(NSNotificationCenter)
- 论文笔记:Faster R-CNN:Towards Real-Time Object Detection with Region Proposal Networks
- RegExp Object
- 151220ObjectDemo
- Objective-C 内存管理机制
- objective-c 我的美图软件
- OObjective-c 二维码(第三方库ZXing)
- objective-c UIImagePickerController 相册视图控制器
- 【已解决】iPhone/iOS中保存自定义对象(Custom Object/Custom Class)的数组(NSMutableArray/NSArray)到NSUserDefaults
- IOS开发系列--Objective-C之KVC、KVO