判断并打开系统设置

参考了这位博主的文章: app


http://www.jianshu.com/p/19602f48309b url

//在应用活跃的时候判断系统设置中的通知是否打开 spa

- (void)applicationDidBecomeActive:(UIApplication *)application { orm

    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. get

          if (SYSTEM_VERSION < 8.0) { it

            if ([[UIApplication sharedApplication] enabledRemoteNotificationTypes] == UIRemoteNotificationTypeNone && !titleView) { io

                titleView = [[SFGlobalAlertView alloc] initWithMessage:@"检测到系统禁止了消息推送,这样会致使您没法及时收到消息" delegate:self type:GlobalAlertViewTypeDefault]; sed

                [titleView setLeftButtonTitle:@"当即设置" imageWithNormalImageName:nil im

                           highlightImageName:nil]; 推送

                [titleView setRightButtonTitle:@"再也不提醒" imageWithNormalImageName:nil highlightImageName:nil];

                titleView.tag = SFGlobalViewTagForNotiSetting;

                [titleView show];

                

            }

            

        }else

        {

            UIUserNotificationType types = [[UIApplication sharedApplication] currentUserNotificationSettings].types;

           

            if (types == UIUserNotificationTypeNone && !titleView) {

                 titleView = [[SFGlobalAlertView alloc] initWithMessage:@"检测到系统禁止了消息推送,这样会致使您没法及时收到消息" delegate:self type:GlobalAlertViewTypeDefault];

                [titleView setLeftButtonTitle:@"当即设置" imageWithNormalImageName:nil

                           highlightImageName:nil];

                [titleView setRightButtonTitle:@"再也不提醒" imageWithNormalImageName:nil highlightImageName:nil];

                [titleView show];

                titleView.tag = SFGlobalViewTagForNotiSetting;

            }

        }

  }

  

//若是没有打开,则进入设置

    if(SYSTEM_VERSION < 8.0)

           {

               [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=INTERNET_TETHERING"]];


           }else

         {

                 NSURL *url =[NSURL URLWithString:UIApplicationOpenSettingsURLString];

             if([[UIApplication sharedApplication] canOpenURL:url]) {

                 

                 [[UIApplication sharedApplication] openURL:url];

                 

             }


         }

  
相关文章
相关标签/搜索