iOS应用内跳转系统设置相关界面的方法
在iOS开发中,有时会有跳转系统设置界面的需求,例如提示用户打开蓝牙或者WIFI,提醒用户打开推送或者位置权限等。在iOS6之后,第三方应用需要跳转系统设置界面,需要在URL type中添加一个prefs值,如下图:
跳转系统设置根目录中的项目使用如下的方法:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
_array = @[
@{@
"系统设置"
:@
"prefs:root=INTERNET_TETHERING"
},
@{@
"WIFI设置"
:@
"prefs:root=WIFI"
},
@{@
"蓝牙设置"
:@
"prefs:root=Bluetooth"
},
@{@
"系统通知"
:@
"prefs:root=NOTIFICATIONS_ID"
},
@{@
"通用设置"
:@
"prefs:root=General"
},
@{@
"显示设置"
:@
"prefs:root=DISPLAY&BRIGHTNESS"
},
@{@
"壁纸设置"
:@
"prefs:root=Wallpaper"
},
@{@
"声音设置"
:@
"prefs:root=Sounds"
},
@{@
"隐私设置"
:@
"prefs:root=privacy"
},
@{@
"APP Store"
:@
"prefs:root=STORE"
},
@{@
"Notes"
:@
"prefs:root=NOTES"
},
@{@
"Safari"
:@
"prefs:root=Safari"
},
@{@
"Music"
:@
"prefs:root=MUSIC"
},
@{@
"photo"
:@
"prefs:root=Photos"
}
];
NSURL * url = [NSURL URLWithString:[_array[index] allValues].firstObject];
[[UIApplication sharedApplication]openURL:url];
|
如果要跳转第三方应用的设置界面中,使用prefs:root=boundleId的方式,boundleId是第三方应用的boundleId。
如果需要继续向项目内层进行跳转,可以通过添加path路径的方式,如下:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
_array = @[
@{@
"关于本机"
:@
"prefs:root=General&path=About"
},
@{@
"软件升级"
:@
"prefs:root=General&path=SOFTWARE_UPDATE_LINK"
},
@{@
"日期时间"
:@
"prefs:root=General&path=DATE_AND_TIME"
},
@{@
"Accessibility"
:@
"prefs:root=General&path=ACCESSIBILITY"
},
@{@
"键盘设置"
:@
"prefs:root=General&path=Keyboard"
},
@{@
"VPN"
:@
"prefs:root=General&path=VPN"
},
@{@
"壁纸设置"
:@
"prefs:root=Wallpaper"
},
@{@
"声音设置"
:@
"prefs:root=Sounds"
},
@{@
"隐私设置"
:@
"prefs:root=privacy"
},
@{@
"APP Store"
:@
"prefs:root=STORE"
},
@{@
"还原设置"
:@
"prefs:root=General&path=Reset"
},
@{@
"应用通知"
:@
"prefs:root=NOTIFICATIONS_ID&path=应用的boundleId"
}
];
|
如下是跳转到系统设置诸多界面的url
使用方法:
然而不幸的是,ios 5.1之后系统不再支持这些url跳转调用到系统。
引用
Yep, saw this (and many more), even implemented it in a test application. Really need to get the definative word from APPL, but the community concensus opinion is APPL disallowed it in 5.1 after it was publically "discovered/published", so applications containing it won't be accepted.
08/01/12 Update: Asked Apple through my developer account if there is a way to programmatically launch the WiFi Settings dialog. Here is the response:
"Our engineers have reviewed your request and have concluded that there is no supported way to achieve the desired functionality given the currently shipping system configurations."
From: http://stackoverflow.com/questions/8246070/ios-launching-settings-restrictions-url-scheme
所以,要么我们干脆干掉这个功能。要么,变态了。
From:
http://my.oschina.net/u/2340880/blog/619224
http://bbs.9ria.com/thread-189867-1-1.html
本文详细介绍如何在iOS应用中实现跳转至系统设置界面的功能,包括蓝牙、Wi-Fi、通知等常见设置项,以及如何跳转至第三方应用的设置界面。

4410

被折叠的 条评论
为什么被折叠?



