alann-maulana / flutter_beacon

An hybrid iBeacon scanner and transmitter SDK for Flutter Android and iOS.
Apache License 2.0
119 stars 146 forks source link

Unable to range and broadcast on Samsung Android 12 #131

Open wieger opened 1 year ago

wieger commented 1 year ago

Hi, I have build an app to scan for beacons using this package. It all works flawlessly on iOS devices but I cannot get it to work on my Android device, a samsung S10 running android 12. I hope that someone which has managed to get it working can help me debug it, or point me towards a step I missed during the setup. To debug it I am now running the example code provided in the repository At first I was missing the proper permissions but I think I have that sorted, combining some previous posts on this forum.

I have the following permissions in main/AndroidManifest.xml

   <uses-permission android:name="android.permission.INTERNET" />
    <!--Before Android 12 (but still needed location, even if not requested)-->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <uses-permission android:name="android.permission.BLUETOOTH" tools:remove="android:maxSdkVersion" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />

    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />

I request the required permissions with the following code, and all statuses resolve to granted

import 'package:permission_handler/permission_handler.dart';  //permission_handler: ^10.2.0

    PermissionStatus scan = await Permission.bluetoothScan.request();
    PermissionStatus connect = await Permission.bluetoothConnect.request();
    PermissionStatus bt = await Permission.bluetooth.request();
    PermissionStatus advertise = await Permission.bluetoothAdvertise.request();

I listen for beacons using: _streamRanging = flutterBeacon.ranging(regions).listen((RangingResult result) { print(result);

this does print a result but it contains no beacons:

I/flutter (27838): {"region":{"identifier":"BeaconType2","proximityUUID":"6a84c716-0f2a-1ce9-f210-6a63bd873dd9"},"beacons":[]}
I/flutter (27838): {"region":{"identifier":"Cubeacon","proximityUUID":"cb10023f-a318-3394-4199-a8730c7c1aec"},"beacons":[]}
I/flutter (27838): {"region":{"identifier":"MyRegion","proximityUUID":"xxxx-x-x-xxxx"},"beacons":[]}

Any help is greatly appreciated, thanks

dalilabennasr commented 1 month ago

@wieger did you find a solution? I'm facing the same issue. Thank you in advance

wieger commented 1 month ago

Unfortunately not, it must be something silly in the configuration. but after spending too much time on it I finally gave up on it. If you do get it to work please post it here!

Regards Wieger

On Wed, Jul 31, 2024 at 2:23 PM Dalila Ben Nasr @.***> wrote:

@wieger https://github.com/wieger did you find a solution? I'm facing the same issue. Thank you in advance

— Reply to this email directly, view it on GitHub https://github.com/alann-maulana/flutter_beacon/issues/131#issuecomment-2260397677, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACZGMJSPEUYG35A3IE52HDZPDJNBAVCNFSM6AAAAABLYLSAQCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRQGM4TONRXG4 . You are receiving this because you were mentioned.Message ID: @.***>

dalilabennasr commented 1 month ago

@wieger do you remember what flutter sdk you were using?

wieger commented 1 month ago

My pubspec.lock for the project says:

sdks: dart: ">=3.2.3 <4.0.0" flutter: ">=3.16.6"

On Wed, Jul 31, 2024 at 2:31 PM Dalila Ben Nasr @.***> wrote:

@wieger https://github.com/wieger do you remember what flutter sdk you were using?

— Reply to this email directly, view it on GitHub https://github.com/alann-maulana/flutter_beacon/issues/131#issuecomment-2260413537, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACZGMNLVG62M7ITKHA6CJTZPDKLFAVCNFSM6AAAAABLYLSAQCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRQGQYTGNJTG4 . You are receiving this because you were mentioned.Message ID: @.***>

dalilabennasr commented 1 month ago

is the project in a git repo? is it public?

wieger commented 1 month ago

Its not public i'm afraid

On Wed, Jul 31, 2024 at 2:39 PM Dalila Ben Nasr @.***> wrote:

is the project in a git repo? is it public?

— Reply to this email directly, view it on GitHub https://github.com/alann-maulana/flutter_beacon/issues/131#issuecomment-2260427115, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACZGMLVV3QSGF7NP4NEH5TZPDLHLAVCNFSM6AAAAABLYLSAQCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRQGQZDOMJRGU . You are receiving this because you were mentioned.Message ID: @.***>