相关疑难解决方法(0)

检测"允许通知"为iOS8打开/关闭

我试图在iOS 8中检测应用程序的本地通知设置

UIUserNotificationSettings,它返回我7我已经把所有的徽章,声音和提醒.

在设置中,我关闭"允许通知",应用程序仍然返回我的UIUserNotificationSettings(徽章,声音和警报).有没有办法检测"允许Notification"开/关?

- (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];
    }
}
Run Code Online (Sandbox Code Playgroud)

ios uilocalnotification ios8

41
推荐指数
6
解决办法
3万
查看次数

标签 统计

ios ×1

ios8 ×1

uilocalnotification ×1