NSURL *url = [NSURL URLWithString:@"APP-Prefs:root=WIFI"]; if ([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; }
NSURL *url = [NSURL URLWithString:@"prefs:root=WIFI"]; if ([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url]; // iOS 9 的跳轉 }
(這屬於老方法了,iOS 10不可用)框架
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; if ([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url]; }
(這方法雖然iOS 10也能夠用可是並不能去到藍牙、WIFI、電池,只能去到自身應用的系統設置。)測試
Pin、Launcher,均可以經過簡單地設置 URL Scheme 實現此功能,你能夠繼續在通知中心直接跳轉至系統設置的特定頁面,好比蜂窩數據、WiFi、定位等等。只需將原來的 prefs
開頭改爲 Prefs
便可。
須要注意的是,這個功能只在通知中心的 Today Widget(即插件)有效,在應用中則沒法直接跳轉設置。url
(若是你的是通知欄類應用能夠用此辦法解決,iOS 10 可用)spa
NSURL *url = [NSURL URLWithString:@"prefs:root=WIFI"]; if ([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; }
和插件
- (void)openURL:(NSURL*)url options:(NSDictionary<NSString *, id> *)options completionHandler:(void (^ __nullable)(BOOL success))completion NS_AVAILABLE_IOS(10_0) NS_EXTENSION_UNAVAILABLE_IOS("");
options
傳nil
和 @{}
以及隨便傳個有鍵值對的字典都是無效。(若是你知道正確使用該API麻煩指點迷津。)code
使用MobileCoreServices.framework
裏的私有API:orm
- (BOOL)openSensitiveURL:(id)arg1 withOptions:(id)arg2;
導入MobileCoreServices.framework框架 #import <MobileCoreServices/MobileCoreServices.h> // Prefs:root=WIFI P要大寫 NSURL *url = [NSURL URLWithString:@"Prefs:root=WIFI"]; Class LSApplicationWorkspace = NSClassFromString(@"LSApplicationWorkspace"); [[LSApplicationWorkspace performSelector:@selector(defaultWorkspace)] performSelector:@selector(openSensitiveURL:withOptions:) withObject:url withObject:nil];
親測可行,可是隨時會有被下架風險。(萬能WiFi鑰匙、WiFi鑰匙上面都用到了。)
要混淆私有API繞過審覈的本身去搜下。blog