用户可能对应用设置是否允许通知,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;
}