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

"bluetooth-central" background mode error on iOS #530

Closed
alextran1502 opened this issue Sep 28, 2020 · 1 comment
Closed

"bluetooth-central" background mode error on iOS #530

alextran1502 opened this issue Sep 28, 2020 · 1 comment

Comments

@alextran1502
Copy link

alextran1502 commented Sep 28, 2020

Hello,

I am having an error when the phone starts to scan for devices on iOS. It would crash the app and throw the exception in Xcode console as follow

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'State restoration of CBCentralManager is only allowed for applications that have specified the "bluetooth-central" background mode'
terminating with uncaught exception of type NSException

Here is the full logs
Screen Shot 2020-09-28 at 4 53 00 PM

I have put the NSBluetoothAlwaysUsageDescription into Info.plist.

Am I missing anything here to have the Bluetooth module working?

Thanks.

@alextran1502
Copy link
Author

alextran1502 commented Sep 29, 2020

Solved the problem by adding the properties below

<key>NSBluetoothAlwaysUsageDescription</key>
<string>The app uses bluetooth to find, connect and transfer data between different devices</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>The app uses bluetooth to find, connect and transfer data between different devices</string>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
</array>

wcoder added a commit to wcoder/FlutterBleLib that referenced this issue Dec 15, 2020
mikolak pushed a commit that referenced this issue Apr 8, 2021
* Add bluetooth-central key to README.md

Based on #530

* Update README.md
mikolak pushed a commit that referenced this issue Apr 13, 2021
* Work in progress

* lib/** nullability compliant;
added linter exceptions for string single quotes and pedantic local variable type rule

* Example:: updated to nullsafe-ready dependencies

* Example:: nullsafety + refactor WIP

* Example:: nullsafe ready

* Example/test:: nullsafe ready

* test:: using new mocking mechanism
additional fixes

* Java: added some null checks to make the calls to stop and destroy reentrant

* Example:: additional cleanup and refactor
Lib:: enchanced error handling, refined nullability on certain types

* TestFix:: the injected manager instance is not part of the Characteristic POD so should be ignored when checking for equallity

* ble_error seem to have rather nullable fields

* TestFix: little refactor on characteristic_mixin regarding clearity and type annotations

* TestFix:: lib_core_test::  tests now passing

* Example:: removed comment-disabled code

* Test:: all tests Passing now! 🎉

* Enhanced BleError nullability, so that reason always has a default value;
made fields final

* Travis fix

* disabled analysis for tests

* Travis:: still fixing ios build

* vscode:: stopped tracking settings file

* travis:: removed my additions to ios example script

* Characteristic:: Service field is now final

* gitignored andoid related staff
xcode noise

* Add bluetooth-central key to README.md (#562)

* Add bluetooth-central key to README.md

Based on #530

* Update README.md

* Travis: updated xcode version to 12.2

* BleError:: default reason text added

* ScanResult::
added final qualifiers
isConnectable is back to nullable since it's only available on iOS on android it will be null which does not mean false!!

* CharacteristicsMixin::
_parseCharacteristicWithValueWithTransactionIdResponse()::
signature is now type safe
moved the rawJsonValue String checking to the caller side

* Test:: removed dummy print

* ScanningMixin:: _prepareScanEventsStream() renamed to just _scanEvents
also _resetScanEvents introduced to null the underlying scream out

* ScanningMixin:: small refinement on naming stuff

* Characteristic:: refactor on Futures to always complete with something even if withResponse is false
additional type safety on invokeMethod calls

* Revert "Characteristic:: refactor on Futures to always complete with something even if withResponse is false"

This reverts commit 86dafd6.

Co-authored-by: Yauheni Pakala <[email protected]>
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

No branches or pull requests

1 participant