13

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?

cbowns
  • 6,295
  • 5
  • 47
  • 64
codester
  • 36,891
  • 10
  • 74
  • 72

2 Answers2

18

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.

  • can you provide the code with which i can open settings from my app on ios 5.1 and ios 6 – codester Jan 29 '13 at 16:32
  • Additionally, you'll need the `com.apple.springboard.openapplications` entitlement. –  Jan 29 '13 at 16:43
  • mapmyfitness app ask on start for open bluetooth option message. i don't think apple while testing did not notice that.May be there's another legal way to do that – codester Jan 29 '13 at 18:22
  • Too bad it's dissallowed, +1 for figuring it out though. – Brandon Buck Apr 09 '13 at 06:42
  • This works for iOS7, too. Great! I had to add a 0 as second argument to dlopen and include "dlfcn.h", though. Did anyone figure out, how to open a specific section in settings this way? – akw Nov 19 '13 at 18:57
  • @akw I don't think you can use this to open the Settings app at a specific section. This function only opens an application, it doesn't let the user specify additional contextual data. –  Nov 19 '13 at 19:47
  • @H2CO3 how to open setting in ios 7? – jpd Nov 29 '13 at 12:05
  • @H2CO3 i have added your code but not working in my app..can u help me? – jpd Nov 29 '13 at 12:23
  • This works in the Simulator in iOS8.3, but not on device. Any thoughts? – dmorrow Jun 05 '15 at 17:57
13

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.

enter image description here

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.

Joris Kluivers
  • 11,894
  • 2
  • 48
  • 47
  • Thanks for your reponse.. On start _mapmyfitness_ shows alert view for open Bluetooth option in setting screen and it has name of app and custom message.It is possible with private Bluetooth api's which is illegal. so how apple passed this app in appstore or is there another legal way to do it? – codester Jan 29 '13 at 18:48
  • Thanks for your help Joris.. can you provide some code to do that. – codester Jan 29 '13 at 19:24
  • see the `CBCentralManager` documentation for it's usage. – Joris Kluivers Jan 29 '13 at 20:49