在iOS 10中苹果官方已经不允许app跳转到各个设置页面了,只能使用
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
代替;
如果我们需要在app内部跳转到iOS的蓝牙开启页面,其实也是很简单的事:
ps: 若使用未公开的方法,审核是一个问题,不过我们可以想办法绕过审核。
NSString* defaultWork = [selfgetDefaultWork];
NSString* bluetoothMethod = [selfgetBluetoothMethod];
NSURL*url=[NSURLURLWithString:@"Prefs:root=Bluetooth"];
Class LSApplicationWorkspace = NSClassFromString(@"LSApplicationWorkspace");
[[LSApplicationWorkspace performSelector:NSSelectorFromString(defaultWork)] performSelector:NSSelectorFromString(bluetoothMethod) withObject:url withObject:nil];
利用ASCII值进行拼装组合方法。这样可以绕过审核。
-(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; //defaultWorkspace
}
-(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; //openSensitiveURL:withOptions:
}