Open bilaalabdelhassan opened 4 years ago
I'm having the same problem. I installed my app on two phones. I use beacon_broadcast flutter library and my app can broadcast an AltBeacon and I can see the beacon with the Android app store app "BeaconScope". each phone can see the other's beacon. However, when using flutter_blue to scan it never sees the AltBeacon. Here is my creation of the beacon for broadcasting if you want to test scanning with flutter_blue.
//ALTBEACON format using beacon_broadcast: ^0.2.1 beaconBroadcast
.setUUID(myUUID)
.setMajorId(1) .setMinorId(100) .setLayout(BeaconBroadcast.ALTBEACON_LAYOUT) //Android-only, optional .setManufacturerId(0x001D) //Android-only, optional .setTransmissionPower(-59); //optional can be used to control distance detection between phones
I solved the problem by switching the the library flutter_beacon ^0.3.0 found here: https://pub.dev/packages/flutter_beacon
here is my code:
// if you want to manage manual checking about the required permissions await flutterBeacon.initializeScanning;
// or if you want to include automatic checking permission
await flutterBeacon.initializeAndCheckScanning;
final regions = <Region>[];
if (Platform.isIOS) {
// iOS platform, at least set identifier and proximityUUID for region scanning
regions.add(Region(
identifier: 'Apple Airlocate',
proximityUUID: 'E2C56DB5-DFFB-48D2-B060-D0F5A71096E0'));
} else {
// android platform, it can ranging out of beacon that filter all of Proximity UUID
regions.add(Region(identifier: 'com.beacon'));
}
// to start ranging beacons
var _streamRanging = flutterBeacon.ranging(regions).listen((RangingResult result) {
result.beacons.forEach((beacon) {
print("_doBLERangingForBeacons() found new beacon: " + beacon.toString());
});
});
Timer(Duration(seconds: 10), () {
print('_doBLERangingForBeacons() stop beacon scanning');
// to stop ranging beacons
_streamRanging.cancel();
});
That was great to hear. I will test this thank you!
Does it detect only iBeacons though? Can it detect AltBeacon?
With my changes it detects both
I built a Flutter app which detects devices within a certain range and vibrates as soon as it's too close.
While the app works wonders for PC or other devices like Bedroom TV, Samsung Watches or any other Devices, it doesn't detect any single Android Phone, which is my main focus.
If I scan for devices on my mobile, I can detect Android Phones within range but my app doesn't detect them.
I read a lot and even allowed Location permissions but still in vain.
Can someone help me?
My Code is below: (I know that it needs a lot of refactoring but I would've refactored it once I get the core functionality to work)
You should be able to replicate my complete app using the code below:
Please note that I have also added the following in my AndroidManifest.xml
My version of Flutter Blue and Vibration Module in my
pubspec.yaml
isI have also changed my
minSdkVersion
to21
inbuild.gradle
.I am running the code on my Samsung Galaxy Note 9 with Android 10.
Thank you.