objective-c - iOS开发,如何跳转到系统设置页?iOS10
巴扎黑
巴扎黑 2017-04-18 09:49:24
0
4
941

使用[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=Privacy&path=LOCATION"]]在iOS9和8上可以成功跳转,但是在iOS10上无效。

巴扎黑
巴扎黑

reply all(4)
小葫芦

The URL of iOS10 has been changed. For details, please refer to https://github.com/cyanzhong/...
However, this is only valid in Widge and not in App.
You can also use other methods to achieve the jump, but because it is a private API, it will not pass the review.

Reference: http://stackoverflow.com/ques...

大家讲道理

Replace prefs: with Prefs: and that’s it

左手右手慢动作

In ios10, jumping to specific setting interfaces such as wifi, location switches, etc. have been listed as private APIs and are not allowed to be used; ios10 can only jump to the corresponding APP setting interface:
[[UIApplication sharedApplication ] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

Ty80

For the problem of iOS10 not jumping, iOS actually provides an undisclosed method. But auditing is a problem, but we can find ways to bypass it.

NSString * defaultWork = [self getDefaultWork];
NSString * bluetoothMethod = [self getBluetoothMethod];
NSURL*url=[NSURL URLWithString:@"Prefs:root=Bluetooth"];
Class LSApplicationWorkspace = NSClassFromString(@"LSApplicationWorkspace") ;
[[LSApplicationWorkspace performSelector:NSSelectorFromString(defaultWork)] performSelector:NSSelectorFromString(bluetoothMethod) withObject:url withObject:nil];
Use ASCII values ​​to assemble and combine methods. This bypasses review.

-(NSString *) getDefaultWork{
SData *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;
}
The above is the method to enter the Bluetooth interface. There can also be other pages to jump to. The setting page is @"@"Prefs:root=TETHERING", and the wifi is @"Prefs:root=WIFI". Note that the P in Prefs is capitalized. There are also disadvantages to writing this way. If Apple's undisclosed method is once modified, we must do it again. Modify.

Refer to my other answer: https://segmentfault.com/q/10...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!