进程间通信
使用URL Schema,就是iOS内的应用调用协议。
IOS10关闭跳转设置子页面,以以下方法通过审核。
#import "HWSkipSystemSettingManager.h"
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
@implementation HWSkipSystemSettingManager
+ (void)skipToWifiSettingView
{
if (UIApplicationOpenSettingsURLString) {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10")) {
NSString *defaultWork = [self getDefaultWork];
NSString *bluetoothMethod = [self getBluetoothMethod];
NSURL *url = [NSURL URLWithString:@"Prefs:root=WIFI"];
Class LSApplicationWorkspace = NSClassFromString(@"LSApplicationWorkspace");
[[LSApplicationWorkspace performSelector:NSSelectorFromString(defaultWork)] performSelector:NSSelectorFromString(bluetoothMethod) withObject:url withObject:nil];
}
else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];
}
}
}
}
+ (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;
}
@end