iOS10跳转至设置页面
在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.plist的LSApplicationQueriesSchemes项中。 - 使用私有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跳转至设置页面的更多相关文章
- 跳转到设置页面 与appstory
//MARK:系统跳到应用设置页面 func systemMySet(){ let url = NSURL(string: UIApplicationOpenSettingsURLString) if ...
- 跳转iPhone设置页面,绕过审核
1.问题描述 跳转iPhone设置页面之前都是通过 App-Prefs:root=WIFI 来跳转,但是2018年6月废弃了这个函数,被认为是私有函数,审核会被拒绝. 有心人采用了字符串转码的方式来规 ...
- 【iOS】跳转到设置页面
iOS8.0以后有效 定位服务 定位服务有很多APP都有,如果用户关闭了定位,那么,我们在APP里面可以提示用户打开定位服务.点击到设置界面设置,直接跳到定位服务设置界面.代码如下: 1 2 3 4 ...
- Android之检查网络是否可用(跳转网络设置页面)
private boolean NetWorkStatus() { ConnectivityManager cwjManager = (ConnectivityManager) getSystemSe ...
- Swift - 判断是否有某功能访问权限,没有则提示,并自动跳转到设置页
由于 iOS 系统的安全限制,App 如果需要访问设备的通讯录.麦克风. 相册. 相机.地理位置等时,需要请求用户是否允许访问. 有时用户不小心点了“不允许”,后面可能就不知道要去哪里再开启这个权 ...
- iOS-退出App程序,进入设置页面
AppDelegate *app = [UIApplication sharedApplication].delegate; UIWindow *window = app.window; ...
- day105:Mofang:设置页面初始化&更新头像/上传头像&设置页面显示用户基本信息
目录 1.设置页面初始化 2.更新头像 1.点击头像进入更新头像界面 2.更新头像页面初始化 3.更新头像页面CSS样式 4.头像上传来源选择:相册/相机 5.调用api提供的本地接口从相册/相机提取 ...
- iOS 从应用中跳转至系统设置页面里的多种设置页面
我们在开发app过程中很多时候会需要设置系统权限,这时就需要在应用中跳转至系统设置页面权限设置页面,以下是自己结合网上的资料总结的一些经验: 直接从应用中跳转至系统设置中这个应用的权限设置页面 NSU ...
- 让超链接点击后不跳转,可以用href = "#",但是这个#就会锚点到页面最上边 点击链接后不跳转可以设置成
让超链接点击后不跳转,可以用href = "#",但是这个#就会锚点到页面最上边 点击链接后不跳转可以设置成 1.<a href="javascri ...
随机推荐
- Web前端基础(10):JavaScript(四)
1. 伪数组arguments arguments代表的是实参.有个讲究的地方是:arguments只在函数中使用. 1.1 返回参数个数 返回函数实参的个数:arguments.length 例子: ...
- js相同的正则多次调用test()返回的值却不同
项目中文件上传需要验证文件的格式,第一次正常,第二次就验证不通过了.在验证的地方console.log()两遍,发现结果不一样 !!! 正则和文件名都没变,但是两次的验证结果不同. this.reg ...
- VMware+node+nginx+vue
1.安装CentOS 这里不再复述,不会的请移步VMware虚拟机安装centos7 2.部署 1.安装 node.js cd /usr/local/ wget https://nodejs.or ...
- socket调试工具(Mac版)
基于Mac版的Socket测试功能,类似于PostMan的功能,对于Socket长链接的项目开发很有帮助. 本人也是通过好多渠道才找到这篇文章,与大家共享: 按照步骤一步一步来就对了~ 本文参考于:h ...
- MySQL基础之常用函数
数学函数的使用 常用数学函数 函数 作用 函数 作用 ceil() 进一取整 abs() 取绝对值 floor() 舍掉小数部分 power() 幂运算 round() 四舍五入 pi() 圆周率 t ...
- Saltstack_使用指南18_API
1. 主机规划 salt 版本 [root@salt100 ~]# salt --version salt (Oxygen) [root@salt100 ~]# salt-minion --versi ...
- Django_xadmin_TypeError: Related Field got invalid lookup: icontains
问题: 当我在给某一张表加上外键搜索的时候,会出现 TypeError: Related Field got invalid lookup: icontains 问题原因: a 表关联 b表,也就是说 ...
- JVM GC算法 垃圾回收器
JVM的垃圾回收算法有三种: 1.标记-清除(mark-sweep):啥都不说,直接上图 2.标记-整理(mark-compact) 3.复制(copy) 分代收集算法 ...
- C语言中倒序输出你输入的数。
int n; scanf("%d",&n); while(n>0) { printf("%d",n%10); n/=10; //其实就是n的自除 ...
- Python程序中的进程操作-进程池(multiprocess.Pool)
目录 一.进程池 二.概念介绍--multiprocess.Pool 三.参数用法 四.主要方法 五.其他方法(了解) 六.代码实例--multiprocess.Pool 6.1 同步 6.2 异步 ...