How to programmatically open the Bluetooth settings in iOS 10
Asked Answered
L

4

13

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

Lilililia answered 28/9, 2016 at 14:41 Comment(0)
M
24
func openBluetooth(){
    let url = URL(string: "App-Prefs:root=Bluetooth") //for bluetooth setting
    let app = UIApplication.shared
    app.openURL(url!)
}

Swift 3.0: working up to iOS 10

Note: This URL is "private API". The app will be rejected by App Store reviewers if used.

Money answered 21/1, 2017 at 7:31 Comment(3)
Do not use this one. Our app was rejected from App Store because of that. "Your app uses the "prefs:root=" non-public URL scheme, which is a private entity. The use of non-public APIs is not permitted on the App Store because it can lead to a poor user experience should these APIs change. Continuing to use or conceal non-public APIs in future submissions of this app may result in the termination of your Apple Developer account, as well as removal of all associated apps from the App Store."Ophthalmia
Our app got rejected as well. You might get through once or twice but Apple routinely checks for private APIs. Please don't use this!Incisure
SO what is the apple approved solution to this?Garden
P
4

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.

Peppery answered 4/12, 2018 at 12:56 Comment(1)
I just started Google Map on my iPhone running on iOS 12 and Google provide a deep link straight to Privacy and Location services..Wheeled
D
1

Until now you cannot access to bluetooth settings from your app from iOS 10. you can see the following link to keep your mind at peace.

https://forums.developer.apple.com/message/146658#146658 Opening the Settings app from another app

Droopy answered 30/9, 2016 at 9:31 Comment(1)
Apple will reject your app and potentially kick you off the store for using either "prefs:root=bluetooth" or "app-prefs:root=bluetooth". Sadly there is no alternative I can find. UIApplicationOpenSettingsURLString is a lousy substitute that takes user to your app's custom settings and will likely confuse users that need to go to Settings > Bluetooth to connect to your device.Mitten
Y
0

Now that iOS 15 seemed to have broken auto-reconnect for known Bluetooth devices (other than audio gadgets), it's extremely annoying. If someone finds a solution, App Store-safe or not, I'm all ears.

Yettayetti answered 23/1, 2022 at 10:29 Comment(1)
Did you find a solution for this ?Collage

© 2022 - 2024 — McMap. All rights reserved.