直接上代码,做个笔记
- (BOOL)isAllowedNotification
{
//iOS8 check if user allow notification
if (IOS8_OR_LATER) {// system is iOS8
UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
if (UIUserNotificationTypeNone != setting.types) {
return YES;
}
} else {//iOS7
UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if(UIRemoteNotificationTypeNone != type) {
return YES;
}
}
return NO;
}