Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically open the Bluetooth settings in iOS 10

I'm trying to access the Bluetooth settings through my application using swift.how can access bluetooth setting?

Xcode version - 8.0 swift - 2.3 iOS - 10

like image 362
rajes Avatar asked Sep 28 '16 14:09

rajes


People also ask

How to open settings in iOS swift?

To open up the settings in Swift code, first get the URL from the openSettingsURLString property that Apple provides. Then open that URL using the openURL method. To put it on an alert dialog with two options, open settings or dismiss, you could follow this code example.


1 Answers

You will not be able to use the solution by @Siddharth jain. The Problem: The app will be rejected by Apple with a warning that you should never use non-public APIs anymore. Otherwise, you could risk your developer program.

As far as I know, all you can do is open the iPhone settings in general (or get lead to your app settings if there are some. To do so you need the following code

guard let url = URL(string: UIApplication.openSettingsURLString) else {
    // Handling errors that should not happen here
    return
}
let app = UIApplication.shared
app.open(url)

By this, you will always get a URL you can use without any problems with apple review.

like image 66
Sonius Avatar answered Sep 21 '22 05:09

Sonius