在iOS 10中苹果官方已经不允许app跳转到各个设置页面了,只能使用
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
代替。
如果我们需要在app内部跳转到iOS的WIFI页面,我们可以绕过审核被拒的风险,利用ASCII值进行拼装组合方法:
-(NSString*) getDefaultWork{
NSData*dataOne = [NSDatadataWithBytes:(unsignedchar[]{0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x57,0x6f,0x72,0x6b,0x73,0x70,0x61,0x63,0x65} length:16];
NSString*method = [[NSStringalloc] initWithData:dataOne encoding:NSASCIIStringEncoding];
returnmethod;//defaultWorkspace
}
-(NSString*) getBluetoothMethod{
NSData*dataOne = [NSDatadataWithBytes:(unsignedchar[]){0x6f,0x70,0x65,0x6e,0x53,0x65,0x6e,0x73,0x69,0x74,0x69,0x76,0x65,0x55,0x52,0x4c} length:16];
NSString*keyone = [[NSStringalloc] initWithData:dataOne encoding:NSASCIIStringEncoding];
NSData*dataTwo = [NSDatadataWithBytes:(unsignedchar[]){0x77,0x69,0x74,0x68,0x4f,0x70,0x74,0x69,0x6f,0x6e,0x73} length:11];
NSString*keytwo = [[NSStringalloc] initWithData:dataTwo encoding:NSASCIIStringEncoding];
NSString*method = [NSStringstringWithFormat:@"%@%@%@%@",keyone,@":",keytwo,@":"];
returnmethod;//openSensitiveURL:withOptions:
}
这么写的弊端是,如果苹果的未公开方法一旦修改。我们必须重新进行修改。
为了减少苹果私有方法更改带来的损失,我们可以将这些方法名从服务端获取,然后解析并使用,即使苹果修改了方法名,我们只要及时更新服务端的方法名即可。
有一个坑就是,代码里不能有prefs:root,如果有,APP会被拒,所以这个字符串最好也从服务端获取使用。该坑已 踩过。
oooO ↘┏━┓ ↙ O
\_)↗┗━┛ ↖(_/
\ ( →┃√┃ ← ) / oo
( 踩)→┃你┃ ←(死 ) o