先说在前
苹果官方文档提到:URL is now considered a private API and use will result in app rejection
。虽然是有可能躲过苹果的检测,但是苹果如果发现你这样用了,app上架是有被拒的风险的。
跳转的方法
if (@available(iOS 10, *)) {
NSURL *url = [NSURL URLWithString:@"App-Prefs:root=Privacy"];
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
} else {
NSURL *url = [NSURL URLWithString:@"prefs:root=Privacy"];
[[UIApplication sharedApplication] openURL:url];
}
iOS 10之前跳转系统设置的路径是:prefs:root=Privacy
iOS 10之后修改了路径的前缀:App-Prefs:root=Privacy
注意!!! iOS 11之后的跳转会把App-Prefs:
后面的内容忽略掉,只是单纯打开设置,唯一可用的是打开当前应用的设置:UIApplicationOpenSettingsURLString
,可见stack overflow。
iOS 11之前打开设置中其他路径:
- 当前应用的设置:
UIApplicationOpenSettingsURLString
(已经是NSString类型) - WIFI:
App-Prefs:root=WIFI
- 蓝牙:
App-Prefs:root=Bluetooth
- 蜂窝数据:
App-Prefs:root=MOBILE_DATA_SETTINGS_ID
- 通知:
App-Prefs:root=NOTIFICATIONS_ID
- 声音:
App-Prefs:root=Sounds
- 通用:
App-Prefs:root=General
- 关于手机:
App-Prefs:root=General&path=About
- 辅助功能:
App-Prefs:root=General&path=ACCESSIBILITY
- 日期与时间:
App-Prefs:root=General&path=DATE_AND_TIME
- 语言与地区:
App-Prefs:root=General&path=INTERNATIONAL
- 还原:
App-Prefs:root=Reset
- 键盘设置:
App-Prefs:root=General&path=Keyboard
- 显示与亮度:
App-Prefs:root=DISPLAY
- 墙纸:
App-Prefs:root=Wallpaper
- Siri:
App-Prefs:root=Siri
- 电池电量:
App-Prefs:root=BATTERY_USAGE
- 隐私:
App-Prefs:root=Privacy
- 定位:
App-Prefs:root=Privacy&path=LOCATION
- 相机:
App-Prefs:root=Privacy&path=CAMERA
- iCloud:
App-Prefs:root=CASTLE
- iTunes Store 与 App Store:
App-Prefs:root=STORE