bluetoothbluetooth-lowenergyuser-permissionsios-bluetooth

How do I get permission for BluetoothScan, BluetoothAdvertise, and BluetoothConnect in iOS in Flutter?


I have requested for Permission using Permission Handler package in flutter but yet I am getting request granted for all request as false. Only getting Permission.bluetooth.isGranted as true.

await [
      Permission.bluetooth,
      Permission.bluetoothScan,
      Permission.bluetoothConnect,
      Permission.bluetoothAdvertise,
    ].request();

 bool blueScanStatus = await Permission.bluetoothScan.isGranted;
    // debugPrint(
    //     "\n==============\n | Bluetooth Scan Permissions: $blueScanStatus | \n==============\n");

    bool blueAdvStatus = await Permission.bluetoothAdvertise.isGranted;
    /* debugPrint(
        "\n==============\n | Bluetooth Advertise Permissions: $blueAdvStatus | \n==============\n");*/

    bool blueStatus = await Permission.bluetooth.isGranted;
    /* debugPrint(
        "\n==============\n | Bluetooth Permissions: $blueStatus | \n==============\n");*/

    bool blueConnectStatus = await Permission.bluetoothConnect.isGranted;

The code is working fine with android getting issue with iOS only. Is there something I need to add on Info.plist or something.enter image description here


Solution

  • This issue has been resolved after doing couple of research I came to conclusion that ios doesn't have BluetoothScan, BluetoohAdvertise and BluetoohConnect. iOS only support Bluetooth Permission method. So I modified the code mentioned below.

    if (Platform.isAndroid){
     Map<Permission, PermissionStatus> blePermissions = await [
      Permission.bluetooth,
      Permission.bluetoothScan,
      Permission.bluetoothConnect,
      Permission.bluetoothAdvertise,
    ].request();
    }