我正在尝试检测 iOS 8 中应用的本地通知设置。
对于 UIUserNotificationSettings
,它返回给我数字 7,因为我已经开启了所有提醒标记、声音和警报。
在设置中,我关闭了“允许通知”,但应用仍然返回数字 7 来表示 UIUserNotificationSettings
(提醒标记、声音和警报已打开)。有没有方法可以检测“允许通知”是否开启或关闭?
- (void)application:(UIApplication *)application
didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{
NSLog(@"---notificationSettings.types %d" , notificationSettings.types );
if(notificationSettings.types!=7){
UIAlertView * alert =[[UIAlertView alloc ] initWithTitle:@"Please turn on Notification"
message:@"Go to Settings > Notifications > App.\n Switch on Sound, Badge & Alert"
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[alert show];
}
}
types == UIUserNotificationType.None
(在 Swift 中)的语句来检查用户是否禁用了推送。 - mathz