startBluetooth method
Starts the Bluetooth services for the Grouplink SDK. This method is used to enable Bluetooth functionality.
Implementation
@override
Future<void> startBluetooth() async {
if (Platform.isIOS) {
try {
await iOSSDKChannel.invokeMethod<String>('startiOSBluetooth');
} on PlatformException catch (e) {
log("Error startiOSBluetooth: ${e.message}");
rethrow;
}
}
if (Platform.isAndroid) {
final bluetoothScanGranted = await Permission.bluetoothScan.isGranted;
final bluetoothConnectGranted =
await Permission.bluetoothConnect.isGranted;
final bluetoothAdvertiseGranted =
await Permission.bluetoothAdvertise.isGranted;
if (!bluetoothScanGranted &&
!bluetoothConnectGranted &&
!bluetoothAdvertiseGranted) {
await [
Permission.bluetooth,
Permission.bluetoothScan,
Permission.bluetoothConnect,
Permission.bluetoothAdvertise,
].request();
}
}
}