iOS 10 App跳轉(zhuǎn)到權(quán)限設(shè)置界面(iOS10之前就不各個(gè)記錄了)
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {}];
}
私有方法跳轉(zhuǎn)
(1)跳轉(zhuǎn)的URL(系統(tǒng)差異可能有些跳轉(zhuǎn)不了)
系統(tǒng)設(shè)置:Prefs:root=INTERNET_TETHERING
WIFI設(shè)置:Prefs:root=WIFI
藍(lán)牙設(shè)置:Prefs:root=Bluetooth
系統(tǒng)通知:Prefs:root=NOTIFICATIONS_ID
通用設(shè)置:Prefs:root=General
顯示設(shè)置:Prefs:root=DISPLAY&BRIGHTNESS
壁紙?jiān)O(shè)置:Prefs:root=Wallpaper
聲音設(shè)置:Prefs:root=Sounds
隱私設(shè)置:Prefs:root=privacy
蜂窩網(wǎng)路:Prefs:root=MOBILE_DATA_SETTINGS_ID
音樂(lè):Prefs:root=MUSIC
APP Store:Prefs:root=STORE
Notes:Prefs:root=NOTES
Safari:Prefs:root=Safari
Music:Prefs:root=MUSIC
Photo:Prefs:root=Photos
關(guān)于本機(jī):Prefs:root=General&path=About
軟件升級(jí):Prefs:root=General&path=SOFTWARE_UPDATE_LINK
日期時(shí)間:Prefs:root=General&path=DATE_AND_TIME
Accessibility:Prefs:root=General&path=ACCESSIBILITY
鍵盤(pán)設(shè)置:Prefs:root=General&path=Keyboard
VPN:Prefs:root=General&path=VPN
還原設(shè)置:Prefs:root=General&path=Reset
應(yīng)用通知:Prefs:root=NOTIFICATIONS_ID&path=應(yīng)用的boundleId
(2)實(shí)現(xiàn)方案MobileCoreServices.framework里的私有API
NSString * defaultWork = [self getDefaultWork];//defaultWorkspace
NSString * bluetoothMethod = [self getBluetoothMethod];//openSensitiveURL:withOptions:
NSURL*url=[NSURL URLWithString:@"Prefs:root=Bluetooth"];
Class LSApplicationWorkspace = NSClassFromString(@"LSApplicationWorkspace");
[[LSApplicationWorkspace performSelector:NSSelectorFromString(defaultWork)] performSelector:NSSelectorFromString(bluetoothMethod) withObject:url withObject:nil];
-(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;
}
-(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;
}
上面是進(jìn)入藍(lán)牙界面的方法州藕。也可以有其他的頁(yè)面可以跳轉(zhuǎn)眷蚓。設(shè)置頁(yè)面是@"@"Prefs:root=TETHERING",wifi是@"Prefs:root=WIFI"蓖租。注意Prefs的P是大寫(xiě)。這么寫(xiě)也有弊端楔壤,如果蘋(píng)果的未公開(kāi)方法一旦修改。我們必須重新進(jìn)行修改。