how some apps can open setting app programmatically within their app

谁说我不能喝 提交于 2019-12-17 22:18:53

问题


I know there are many questions: "How to open setting app programatically?" and the answer is "BIG NO". I know that Apple does not support opening Settings from any other app after iOS 5.0.

But there are some apps like MapMyFitness which can open Settings, and they are available in the App Store and have been approved by Apple. MapMyFitness opens the Bluetooth settings if Bluetooth is turned off. I have checked this in iOS 6 and iOS 5.1.

I want to know how can these apps are able to open Settings legally and bypassed Apple security because as per my information there is no legal way to do it?


回答1:


Apps cannot open the settings application to a specific screen. The reason that apps like MapMyFitness open preferences is because they ask for permission to use Bluetooth Low Energy. Asking for permission is managed by CBCentralManager on first usage.

This is also the class that knows if Bluetooth is turned on or off. It will show an alert automatically with an option to go into settings to turn bluetooth on.

A similar popup will be shown when using location services.

These popups are shown automatically by the system framework. The message can be customized using the purpose property for location services, that is not possible in case of Bluetooth.

No private API was used for this, so there's no reason for the app to be rejected.




回答2:


Well, on iOS 5.0, there's the prefs:// URL scheme.

From iOS 5.1, that was removed. It's still possible to use private APIs and obfuscation to bypass the static analysis of the binary. Example:

void (*openApp)(CFStringRef, Boolean);
void *hndl = dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices");
openApp = dlsym(hndl, "SBSLaunchApplicationWithIdentifier");
openApp(CFSTR("com.apple.Preferences"), FALSE);

By playing with the strings (splitting and concatenating them, etc.) you can eventually make it to the AppStore. It's still disallowed, though.



来源:https://stackoverflow.com/questions/14587370/how-some-apps-can-open-setting-app-programmatically-within-their-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!