Passive Read
Flutter ==> Bluetooth module
Some Bluetooth peripherals support passive reading (collecting readings without the app in the foreground). For information on permissions setup and other requirements, please review the iOS and Android native documentation.
To start passively listening to certain peripherals, pass an array of peripheralIDs
to ValidicBluetooth.setPassivePeripheralIDs()
:
// Set passive peripheral IDs to be scanned and read from in the background
await ValidicBluetooth.setPassivePeripheralIDs(peripheralIDs);
To stop passively listening, pass an empty array:
// Set passive peripheral IDs to be scanned and read from in the background
await ValidicBluetooth.setPassivePeripheralIDs();
iOS Background Mode
Passive Reading requires that an additional Background Mode capability be added to a Flutter application's Info.plist
before BluetoothPeripherals can be monitored.
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
</array>
Additionally, a privacy usage statement must be added.
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Allow reading from bluetooth peripherals in the background</string>
The host application must be at least launched in the background for readings to be collected from devices when they advertise an available reading
Android
If the host application is closed by the user and a Bluetooth Peripheral advertises a new reading the App will relaunch and collect the reading.
Special Considerations
Special Considerations
Please review the native Android and native iOS documentation for details on special considerations for specific peripherals.
Updated 1 day ago