how some apps can open setting app programmaticall

2020-02-07 19:34发布

问题:

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.