Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay Bluetooth permission & turn-on-Bluetooth system popups on iOS #964

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jasaw
Copy link

@jasaw jasaw commented Oct 18, 2021

PR #599 delays centralManager initialization, but instantiating FlutterBlue in flutter calls into _setLogLevelIfAvailable() which calls into isAvailable and triggers a popup anyway.
This PR skips isAvailable call in the FlutterBlue constructor and allows setting of log level without initializing centralManager.
The side effect of this change is, for some reason, Bluetooth permission always returns "denied" until centralManager is initialized. Similarly, Bluetooth permission under App Settings does not appear until centralManager is initialized.

rohansingh and others added 2 commits October 18, 2021 15:04
By deferring the initialization of `CBCentralManager`, we are able to
defer prompting for Bluetooth permission on iOS until a flutter_blue
method is called. Otherwise, the Bluetooth permission prompt appears
right when the app starts up.
@jasaw jasaw changed the title Delay Bluetooth permission & turn-on system popups on iOS Delay Bluetooth permission & turn-on-Bluetooth system popups on iOS Oct 18, 2021
@jasaw
Copy link
Author

jasaw commented Oct 25, 2021

This PR has the unfortunate side effect where calling isOn always returns false if centralManager is initialized in the same call. This is caused by race condition of reading the Bluetooth state while the Bluetooth subsystem is still initializing.

@politebarista
Copy link

The bug is still being reproduced even in the master branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants