欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

iOS----------获取通知状态并跳转设置界面设置

程序员文章站 2023-01-28 16:12:19
跳转app对应的系统通知设置 if (UIApplicationOpenSettingsURLString != NULL) { UIApplication *application = [UIApplication sharedApplication]; NSURL *URL = [NSURL U ......

跳转app对应的系统通知设置

    if (uiapplicationopensettingsurlstring != null) {

        uiapplication *application = [uiapplication sharedapplication];

        nsurl *url = [nsurl urlwithstring:uiapplicationopensettingsurlstring];

        if ([application respondstoselector:@selector(openurl:options:completionhandler:)]) {

            [application openurl:url options:@{} completionhandler:nil];

        } else {

            [application openurl:url];

        }

    }

 获取用户通知中心对程序消息通知的设置,是否开启消息通知

    if ([[uidevice currentdevice].systemversion floatvalue]>=8.0f) {

        uiusernotificationsettings *setting = [[uiapplication sharedapplication] currentusernotificationsettings];

        if (uiusernotificationtypenone == setting.types) {

            nslog(@"推送关闭");

        }else{

            nslog(@"推送打开");

        }

    }else{

        uiremotenotificationtype type = [[uiapplication sharedapplication] enabledremotenotificationtypes];

        if(uiremotenotificationtypenone == type){

            nslog(@"推送关闭");

        }else{

            nslog(@"推送打开");

        }

    } 

 在ios应用程序中打开设备设置界面及其中某指定的选项界面

    [[uiapplicationsharedapplication] openurl:[nsurl urlwithstring:@”prefs:root=general”]];

    [[uiapplicationsharedapplication] openurl:[nsurl urlwithstring:@”prefs:root=general&path=restrictions”]];