判斷並打開系統設置

參考了這位博主的文章: 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];

                 

             }


         }

  
相關文章
相關標籤/搜索