iOS应用内跳转到指定系统设置页
APP的跳转: 通过[ [UIApplication sharedApplication] openURL:url]这种方法来实现的。
iOS 10以后跳转设置页要用
[[UIApplication sharedApplication] openURL:url参数 options:options字典参数 completionHandler:^(BOOL success) {
}];
如果我们想从应用bundleID:com.app.app的APP内跳转到系统设置中该应用的设置:
[[UIApplication sharedApplication]openURL:[NSURLURLWithString:@"prefs:root=com.app.app"]];
跳转url为prefs:root=com.app.app"
,所以如果你想跳转到具体某个应用的设置,就必须知道该应用的bundleID
再例如,如果跳转到通知设置中该应用的设置:
跳转url为:prefs:root=NOTIFICATIONS_ID&&path=com.app.app
URL Scheme
URL Scheme 就是实现跳转URL协议的名称(可以多个)。
而APP的跳转就需要设置“URL Schemes”来实现:
跳转到本应用的设置页面
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication]openURL:url options:@{} completionHandler:^(BOOL success) {
}];
}else{
//[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]] 应用标识
NSURL * url = [NSURL URLWithString:[NSString stringWithFormat:@"prefs:root=%@",[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]]];
[[UIApplication sharedApplication]openURL:url];
}
以下指令 分别跳转到 对应页面:
App-Prefs:root
iOS10支持的下放的所有跳转,当然iOS 10以下版本也支持
跳转的URL写法:
无线局域网 App-Prefs:root=WIFI
蓝牙 App-Prefs:root=Bluetooth
蜂窝移动网络 App-Prefs:root=MOBILE_DATA_SETTINGS_ID
个人热点 App-Prefs:root=INTERNET_TETHERING
运营商 App-Prefs:root=Carrier
通知 App-Prefs:root=NOTIFICATIONS_ID
通用 App-Prefs:root=General
通用-关于本机 App-Prefs:root=General&path=About
通用-键盘 App-Prefs:root=General&path=Keyboard
通用-辅助功能 App-Prefs:root=General&path=ACCESSIBILITY
通用-语言与地区 App-Prefs:root=General&path=INTERNATIONAL
通用-还原 App-Prefs:root=Reset
墙纸 App-Prefs:root=Wallpaper
Siri App-Prefs:root=SIRI
隐私 App-Prefs:root=Privacy
Safari App-Prefs:root=SAFARI
音乐 App-Prefs:root=MUSIC
音乐-均衡器 App-Prefs:root=MUSIC&path=com.apple.Music:EQ
照片与相机 App-Prefs:root=Photos
FaceTime App-Prefs:root=FACETIME
使用例子:
NSString * urlStr = @"App-Prefs:root=General&path=About";
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
NSURL * url = [NSURL URLWithString:urlStr];
[[UIApplication sharedApplication]openURL:url options:@{} completionHandler:^(BOOL success) {
}];
}else{
NSURL * url = [NSURL URLWithString:urlStr];
[[UIApplication sharedApplication]openURL:url];
}