您的位置:首页 > 移动开发 > Objective-C

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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: