美文网首页
私有API-iOS10 openURL方法跳转到设置界面失效的解

私有API-iOS10 openURL方法跳转到设置界面失效的解

作者: Code丶Ling | 来源:发表于2016-10-22 17:02 被阅读571次

    http://www.jianshu.com/p/ee666b21e0a9

    解决方法

    可以使用MobileCoreServices.framework里的私有API:

    - (BOOL)openSensitiveURL:(id)arg1 withOptions:(id)arg2;

    头文件参考:LSApplicationWorkspace.h

    使用方法:

    //注意首字母改成了大写,prefs->Prefs

    NSURL*url=[NSURLURLWithString:@"Prefs:root=Privacy&path=LOCATION"];

    Class LSApplicationWorkspace =NSClassFromString(@"LSApplicationWorkspace");

    [[LSApplicationWorkspace performSelector:@selector(defaultWorkspace)] performSelector:@selector(openSensitiveURL:withOptions:) withObject:url withObject:nil];

    MobileCoreServices.framework不是私有库,所以直接使用performSelector:即可调用私有API

    注意

    iOS10的系统URLScheme改成了首字母大写,使用小写的方式会无法打开。

    使用私有API的app无法通过App Store审核。你也可以尝试把私有类名和selector字符串混淆一下,绕过审核。例如这位仁兄用ASCII混淆的方法:

    - (UIView*)statusBarView {

    UIView*statusBar =nil;

    NSData*data = [NSDatadataWithBytes:(unsignedchar[]){0x73,0x74,0x61,0x74,0x75,0x73,0x42,0x61,0x72} length:9];

    NSString*key = [[NSStringalloc] initWithData:data encoding:NSASCIIStringEncoding];

    id object = [UIApplicationsharedApplication];

    if([object respondsToSelector:NSSelectorFromString(key)])

     {        

    statusBar = [object valueForKey:key];    

     }

    returnstatusBar;

     }

    不过,还是不建议使用私有API,因为它是不可靠的。也许某天苹果就把它移除了。

    -`电池电量`Prefs:root=BATTERY_USAGE

    -`通用设置`Prefs:root=General

    -`存储空间`Prefs:root=General&path=STORAGE_ICLOUD_USAGE/DEVICE_STORAGE

    -`蜂窝数据`Prefs:root=MOBILE_DATA_SETTINGS_ID

    -`Wi-Fi设置`Prefs:root=WIFI

    -`蓝牙设置`Prefs:root=Bluetooth

    -`定位设置`Prefs:root=Privacy&path=LOCATION

    -`辅助功能`Prefs:root=General&path=ACCESSIBILITY

    -`关于手机`Prefs:root=General&path=About

    -`键盘设置`Prefs:root=General&path=Keyboard

    -`显示设置`Prefs:root=DISPLAY

    -`声音设置`Prefs:root=Sounds

    -`App Store设置`Prefs:root=STORE

    -`墙纸设置`Prefs:root=Wallpaper

    -`打开电话`Mobilephone://

    -`世界时钟`Clock-worldclock://

    -`闹钟`Clock-alarm://

    -`秒表`Clock-stopwatch://

    -`倒计时`Clock-timer://

    -`打开相册`Photos://

    私有API:https://github.com/JaviSoto/iOS10-Runtime-Headers/blob/master/Frameworks/MobileCoreServices.framework/LSApplicationWorkspace.h

    相关文章

      网友评论

          本文标题:私有API-iOS10 openURL方法跳转到设置界面失效的解

          本文链接:https://www.haomeiwen.com/subject/oidhuttx.html