在iOS10之前,跳转到系统设置界面的某个指定界面的方式如下:

//打开定位服务界面
NSURL*url=[NSURL URLWithString:@"prefs:root=Privacy&path=LOCATION"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
};

但是在iOS10上,调用canOpenURL:打开系统设置界面时控制台会报如下错误,并且无法跳转:
-canOpenURL: failed for URL: "Prefs:root=Privacy&path=LOCATION" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

原因是iOS10只允许跳转到设置里自己app的界面,对跳转到其他界面做了限制.

 

解决方法

1跳转到设置里自己app的界面:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

2可以使用MobileCoreServices.framework里的私有API:

- (BOOL)openSensitiveURL:(id)arg1 withOptions:(id)arg2;
//注意首字母改成了大写,prefs->Prefs
NSURL*url=[NSURL URLWithString:@"Prefs:root=Privacy&path=LOCATION"];
Class LSApplicationWorkspace = NSClassFromString(@"LSApplicationWorkspace");
[[LSApplicationWorkspace performSelector:@selector(defaultWorkspace)] performSelector:@selector(openSensitiveURL:withOptions:) withObject:url withObject:nil];
  • iOS10的系统URLScheme改成了首字母大写,使用小写的方式会无法打开。
  • app需要添加一个Prefs的URL Schemes,即添加到info.plistLSApplicationQueriesSchemes项中。
  • 使用私有API的app无法通过App Store审核。你也可以尝试把私有类名和selector字符串混淆一下,采用ASC码绕过审核。

例如:

NSString * defaultWork = [self getDefaultWork];

NSString * bluetoothMethod = [self getBluetoothMethod];

NSURL *url=[NSURL URLWithString:@"Prefs:root=Bluetooth"];

Class LSApplicationWorkspace = NSClassFromString(@"LSApplicationWorkspace");

[[LSApplicationWorkspace  performSelector:NSSelectorFromString(defaultWork)]                  performSelector:NSSelectorFromString(bluetoothMethod) withObject:url withObject:nil];

//采用ASC码输出defaultWorkspace-----项目中不要写这条注释

-(NSString *) getDefaultWork{

NSData *dataOne = [NSData dataWithBytes:(unsigned char []){0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x57,0x6f,0x72,0x6b,0x73,0x70,0x61,0x63,0x65} length:16];

NSString *method = [[NSString alloc] initWithData:dataOne encoding:NSASCIIStringEncoding];

return method;

}

//采用ASC码输出openSensitiveURL:withOptions----项目中不要写这条注释

-(NSString *) getBluetoothMethod{

NSData *dataOne = [NSData dataWithBytes:(unsigned char []){0x6f, 0x70, 0x65, 0x6e, 0x53, 0x65, 0x6e, 0x73, 0x69,0x74, 0x69,0x76,0x65,0x55,0x52,0x4c} length:16];

NSString *keyone = [[NSString alloc] initWithData:dataOne encoding:NSASCIIStringEncoding];

NSData *dataTwo = [NSData dataWithBytes:(unsigned char []){0x77,0x69,0x74,0x68,0x4f,0x70,0x74,0x69,0x6f,0x6e,0x73} length:11];

NSString *keytwo = [[NSString alloc] initWithData:dataTwo encoding:NSASCIIStringEncoding];

NSString *method = [NSString stringWithFormat:@"%@%@%@%@",keyone,@":",keytwo,@":"];

return method;

}

其他设置页面的url:

About — prefs:root=General&path=About
Accessibility — prefs:root=General&path=ACCESSIBILITY
Airplane Mode On — prefs:root=AIRPLANE_MODE
Auto-Lock — prefs:root=General&path=AUTOLOCK
Brightness — prefs:root=Brightness
Bluetooth — prefs:root=General&path=Bluetooth
Date & Time — prefs:root=General&path=DATE_AND_TIME
FaceTime — prefs:root=FACETIME
General — prefs:root=General
Keyboard — prefs:root=General&path=Keyboard
iCloud — prefs:root=CASTLE
iCloud Storage & Backup — prefs:root=CASTLE&path=STORAGE_AND_BACKUP
International — prefs:root=General&path=INTERNATIONAL
Location Services — prefs:root=LOCATION_SERVICES
Music — prefs:root=MUSIC
Music Equalizer — prefs:root=MUSIC&path=EQ
Music Volume Limit — prefs:root=MUSIC&path=VolumeLimit
Network — prefs:root=General&path=Network
Nike + iPod — prefs:root=NIKE_PLUS_IPOD
Notes — prefs:root=NOTES
Notification — prefs:root=NOTIFICATIONS_ID
Phone — prefs:root=Phone
Photos — prefs:root=Photos
Profile — prefs:root=General&path=ManagedConfigurationList
Reset — prefs:root=General&path=Reset
Safari — prefs:root=Safari
Siri — prefs:root=General&path=Assistant
Sounds — prefs:root=Sounds
Software Update — prefs:root=General&path=SOFTWARE_UPDATE_LINK
Store — prefs:root=STORE
Twitter — prefs:root=TWITTER
Usage — prefs:root=General&path=USAGE
VPN — prefs:root=General&path=Network/VPN
Wallpaper — prefs:root=Wallpaper
Wi-Fi — prefs:root=WIFI
 

iOS10跳转至设置页面的更多相关文章

  1. 跳转到设置页面 与appstory

    //MARK:系统跳到应用设置页面 func systemMySet(){ let url = NSURL(string: UIApplicationOpenSettingsURLString) if ...

  2. 跳转iPhone设置页面,绕过审核

    1.问题描述 跳转iPhone设置页面之前都是通过 App-Prefs:root=WIFI 来跳转,但是2018年6月废弃了这个函数,被认为是私有函数,审核会被拒绝. 有心人采用了字符串转码的方式来规 ...

  3. 【iOS】跳转到设置页面

    iOS8.0以后有效 定位服务 定位服务有很多APP都有,如果用户关闭了定位,那么,我们在APP里面可以提示用户打开定位服务.点击到设置界面设置,直接跳到定位服务设置界面.代码如下: 1 2 3 4 ...

  4. Android之检查网络是否可用(跳转网络设置页面)

    private boolean NetWorkStatus() { ConnectivityManager cwjManager = (ConnectivityManager) getSystemSe ...

  5. Swift - 判断是否有某功能访问权限,没有则提示,并自动跳转到设置页

    由于 iOS 系统的安全限制,App 如果需要访问设备的通讯录.麦克风. 相册. 相机.地理位置等时,需要请求用户是否允许访问.   有时用户不小心点了“不允许”,后面可能就不知道要去哪里再开启这个权 ...

  6. iOS-退出App程序,进入设置页面

     AppDelegate *app = [UIApplication sharedApplication].delegate;     UIWindow *window = app.window;   ...

  7. day105:Mofang:设置页面初始化&更新头像/上传头像&设置页面显示用户基本信息

    目录 1.设置页面初始化 2.更新头像 1.点击头像进入更新头像界面 2.更新头像页面初始化 3.更新头像页面CSS样式 4.头像上传来源选择:相册/相机 5.调用api提供的本地接口从相册/相机提取 ...

  8. iOS 从应用中跳转至系统设置页面里的多种设置页面

    我们在开发app过程中很多时候会需要设置系统权限,这时就需要在应用中跳转至系统设置页面权限设置页面,以下是自己结合网上的资料总结的一些经验: 直接从应用中跳转至系统设置中这个应用的权限设置页面 NSU ...

  9. 让超链接点击后不跳转,可以用href = "#",但是这个#就会锚点到页面最上边 点击链接后不跳转可以设置成

    让超链接点击后不跳转,可以用href = "#",但是这个#就会锚点到页面最上边     点击链接后不跳转可以设置成     1.<a href="javascri ...

随机推荐

  1. 整理了8个Python中既冷门又实用的技巧

    1.print 打印带有颜色的信息 大家知道 Python 中的信息打印函数 print,一般我们会使用它打印一些东西,作为一个简单调试. 但是你知道么,这个 Print 打印出来的字体颜色是可以设置 ...

  2. JMeter压测“java.net.BindException: Address already in use: connect”解决方法

    之前在windows机上用JMeter压测,50并发下出现大量接口报“java.net.BindException: Address already in use: connect”错误. 从字面的意 ...

  3. js-事件函数调用简化

    // 一般写法 function fn(event) { console.log(event) } div.onclick = function (event) { fn(event) } ===== ...

  4. Shell—常见报错问题

    bash:$'\r': command not found 造成这个问题的原因是Windows环境下换行的“\r”到了Linux环境下不能够识别了,因为Linux环境下默认的换行符为“\n”,我们只需 ...

  5. s3c2440裸机-UART编程(二、UART编程实现)

    UART编程 1.初始化 我们的2440支持3个UART串口,以uart0为例讲解. 那么我们需要实现以下这几个函数完成串口的最基本功能: (1)uart0_init()用于初始化串口 (2)putc ...

  6. optix之纹理使用

    1.在OpenGL中生成纹理texture optix中的纹理直接使用OpenGL纹理的id,不能跨越OpenGL纹理,所以我们先在OpenGL环境下生成一张纹理. 这个过程就很熟悉了: void W ...

  7. springmvc 什么时候 set applicationContext 到 ServletConfig 的?

    springmvc 什么时候 set applicationContext 到 ServletConfig 的? FrameworkServlet --> initWebApplicationC ...

  8. poj 2431 Expedition 贪心 优先队列 题解《挑战程序设计竞赛》

    地址 http://poj.org/problem?id=2431 题解 朴素想法就是dfs 经过该点的时候决定是否加油 中间加了一点剪枝 如果加油次数已经比已知最少的加油次数要大或者等于了 那么就剪 ...

  9. 纠错:Feign 没用 短连接

    Feign 默认不是 短连接 疯狂创客圈 Java 高并发[ 亿级流量聊天室实战]实战系列 [博客园总入口 ] 疯狂创客圈(笔者尼恩创建的高并发研习社群)Springcloud 高并发系列文章,将为大 ...

  10. LeetCode 71.简化路径

    LeetCode 71.简化路径 题目描述: 以 Unix 风格给出一个文件的绝对路径,你需要简化它.或者换句话说,将其转换为规范路径.在 Unix 风格的文件系统中,一个点(.)表示当前目录本身:此 ...