To have the dialog prompt at right timing, CBManager can be initialized lazily, therefore, the permission dialog is prompt when needed instead of startup.
The first call of any bluetooth related method will trigger checkBluetoothAdapter() , initialize CBManager and prompt dialog.
They might be another way to achieve this result, (like setting CBCentralManagerOptionShowPowerAlertKey to 0 and ask to enable bluetooth later on) but I found that asking for enabling bluetooth on usage is the most natural way.
Hello, first of all, thank you for your amazing work
On iOS, using your library automatically prompt a "Turn On Bluetooth to Allow [app name] to Connect to Accessories" dialog on app launch.
For a better user experience, it is recommended to ask the user to enable bluetooth when the application really need it.
Found out that initialize CBCentralManager automatically prompt the bluetooth dialog by default. See CBCentralManagerOptionShowPowerAlertKey
To have the dialog prompt at right timing, CBManager can be initialized lazily, therefore, the permission dialog is prompt when needed instead of startup. The first call of any bluetooth related method will trigger
checkBluetoothAdapter()
, initialize CBManager and prompt dialog.They might be another way to achieve this result, (like setting
CBCentralManagerOptionShowPowerAlertKey
to0
and ask to enable bluetooth later on) but I found that asking for enabling bluetooth on usage is the most natural way.