f93
1
Before iOS 10 it was possible to open bluetooth settings via:
UIApplication.shared.openURL(URL(string: "prefs:root=Bluetooth")!)
This no longer works in iOS 10.
However the Estimote demo app on iOS 10 is still able to open the bluetooth preferences.
How does it do that?
Hello!
You need to try:
UIApplication.shared.openURL(URL(string:UIApplicationOpenSettingsURLString)!)
Does it help?
Kate
IT Craft (https://itechcraft.com)
f93
3
Hi Kateryna,
thanks for your answer.
However, UIApplicationOpenSettingsURLString
opens the app’s settings and not the bluetooth settings.
As I want the user to enable bluetooth that doesn’t help and is rather confusing.
The prompt in the iOS app is actually from initializing CBCentralManager
with the CBCentralManagerOptionShowPowerAlertKey
option enabled.
https://developer.apple.com/reference/corebluetooth/cbcentralmanager/1519001-init
https://developer.apple.com/reference/corebluetooth/cbcentralmanageroptionshowpoweralertkey
Since this is from Apple’s own Core Bluetooth framework, I guess it might be using some private API.
f93
5
Thanks Piotr,
that seems to be exactly what I need.
I’ve read the docs and tried a bunch of different implementations but the alert never shows up.
This is how I’m initializing:
bm = CBCentralManager(delegate: self, queue: nil, options: [ CBCentralManagerOptionShowPowerAlertKey: true ])
any ideas?