dotintent / FlutterBleLib

Bluetooth Low Energy library for Flutter with support for simulating peripherals
Apache License 2.0
535 stars 197 forks source link

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

Closed alextran1502 closed 3 years ago

alextran1502 commented 3 years ago

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 commented 3 years ago

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>