How to programmatically open Bluetooth settings in iOS 10

I am trying to access the Bluetooth settings through my application using swift.how can I access the Bluetooth settings?

Xcode Version - 8.0 Fast - 2.3 iOS - 10

+10
source share
3 answers
func openBluetooth(){ let url = URL(string: "App-Prefs:root=Bluetooth") //for bluetooth setting let app = UIApplication.shared app.openURL(url!) } 

Swift 3.0: work in all versions of iOS

+27
source

Until now, you cannot access the Bluetooth settings from your application with iOS 10. You can see the following link to keep the world at ease.

https://forums.developer.apple.com/message/146658#146658 Opening the settings application from another application

+2
source

You cannot use the @Siddharth jain solution. Problem: The application will be rejected by Apple with a warning that you should no longer use non-public APIs. Otherwise, you may risk your developer program.

As far as I know, all you can do is open the iPhone settings in general (or bring them to the application settings, if any. For this 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) 

This way you will always get a URL that you can use without any problems with your apple review.

0
source

Source: https://habr.com/ru/post/1257401/


All Articles