how some apps can open setting app programmatically within their app

不想你离开。 提交于 2019-11-28 17:59:55

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.

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.

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