Open the Bluetooth settings by pressing the button

I watched for a long time how it was possible in iOS 5.1 and below, and that this is impossible in any version above this.

But how do other applications do this?

So far I have tried the following (tested on iOS 8.1 simulator, on Xcode ):

- (void)turnOnBlueToothPressed:(id)sender { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; } 

Which opens the application settings. Not perfect, but that's what it is.

AFAIK using the following:

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Bluetooth"]] 

Does not work any more. Alternatively, can someone point me to the official documentation , which says that it no longer works in any version> iOS 5.1 ?

+4
source share
3 answers

I have the same problem, now you can only open the current application settings, sorry ..... = ( https://developer.apple.com/library/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS8.html

+2
source

This works in iOS version 5.1 and higher .

You should add prefs URL schemes in URL types on the Xcode info.plist tab, as shown below:

url types in info.plist tab

Objective-c

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]]; 

Swift

 UIApplication.sharedApplication().openURL(NSURL(string: "prefs:root=WIFI")!) 

This will open the WIFI settings from your application.

Related SO links:

+2
source

If you want to open the Bluetooth settings:

Swift 3:

 let url = URL(string: "App-Prefs:root=Bluetooth") let app = UIApplication.shared app.openURL(url!) 
0
source

All Articles