alann-maulana / flutter_beacon

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

Unable to detect Android devices #55

Closed huitingyeong closed 3 years ago

huitingyeong commented 4 years ago

Hi, I used the plugin and the example code provided. My iOS device is able to detect other iOS device. Android can detect iOS devices. But both iOS and Android are not able to detect Android devices.

Any idea why?

dariocavada commented 4 years ago

What is meant by "detect" other devices? Has a beacon simulator been activated on other devices? Can you indicate an example of the test you did and the versions of iOS and Android used?

I don't know if the requested functionality matches the functionality of this package which is to locate just iBeacons.

AkshayNG commented 4 years ago

The package is for detecting iBeacon only. So you need to turn your android device into iBeacon using :

if(Platform.isAndroid) {
      beaconBroadcast.setLayout('m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24')
          .setManufacturerId(0x004C);
}

where beaconBroadcast is an instance of BeaconBroadcast

jjakob666 commented 4 years ago

You could edit the FlutterBeaconPlugin.java to add support for Altbeacon as well as iBeacon

public static final String IBEACON_LAYOUT = "m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"; public static final String ALTBEACON_LAYOUT = "m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"; public static final String EDDYSTONE_TLM_LAYOUT = "x,s:0-1=feaa,m:2-2=20,d:3-3,d:4-5,d:6-7,d:8-11,d:12-15"; public static final String EDDYSTONE_UID_LAYOUT = "s:0-1=feaa,m:2-2=00,p:3-3:-41,i:4-13,i:14-19"; public static final String EDDYSTONE_URL_LAYOUT = "s:0-1=feaa,m:2-2=10,p:3-3:-41,i:4-21v"; public static final String URI_BEACON_LAYOUT = "s:0-1=fed8,m:2-2=00,p:3-3:-41,i:4-21v";

private final BeaconParser iBeaconLayout = new BeaconParser() .setBeaconLayout(IBEACON_LAYOUT); private final BeaconParser altBeaconLayout = new BeaconParser() .setBeaconLayout(ALTBEACON_LAYOUT);

private void initialize() {
beaconManager = BeaconManager.getInstanceForApplication(registrar.context());
if (!beaconManager.getBeaconParsers().contains(iBeaconLayout)) {
  beaconManager.getBeaconParsers().clear();
  beaconManager.getBeaconParsers().add(iBeaconLayout);
  beaconManager.getBeaconParsers().add(altBeaconLayout);
}

}

jjakob666 commented 4 years ago

The package is for detecting iBeacon only. So you need to turn your android device into iBeacon using :

if(Platform.isAndroid) {
      beaconBroadcast.setLayout('m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24')
          .setManufacturerId(0x004C);
}

where beaconBroadcast is an instance of BeaconBroadcast

This doesn't work on Android. Fails to broadcast the beacon. The best is to fix flutter_beacon to accept and detect/range AltBeacons so it works with beacon_broadcast. See my post above for the fix

AkshayNG commented 4 years ago

This doesn't work on Android. Fails to broadcast the beacon. The best is to fix flutter_beacon to accept and detect/range AltBeacons so it works with beacon_broadcast. See my post above for the fix

Not sure whats wrong, broadcasting is working fine my side. But I'll try out the solution you suggested. Also would it range the beacons in background for android 8.0+ ? I'm facing https://github.com/alann-maulana/flutter_beacon/issues/61. Please help @jjakob666

jjakob666 commented 4 years ago

The two devices I have (Amazon FireHD tablet) and my samsung S9 don't have an issue. no special code needed, I switch to another app and the data still comes in.

On Sun, Jun 14, 2020 at 3:07 AM Akshay Gajarlawar notifications@github.com wrote:

This doesn't work on Android. Fails to broadcast the beacon. The best is to fix flutter_beacon to accept and detect/range AltBeacons so it works with beacon_broadcast. See my post above for the fix

Not sure whats wrong, broadcasting is working fine my side. But I'll try out the solution you suggested. Also would it range the beacons in background for android 8.0+ ? I'm facing #61 https://github.com/alann-maulana/flutter_beacon/issues/61. Please help @jjakob666 https://github.com/jjakob666

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/alann-maulana/flutter_beacon/issues/55#issuecomment-643728439, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM7GZZCSVPPJUMLVEIDTPTDRWRZLFANCNFSM4MSRCRWA .

jjakob666 commented 4 years ago

Also I run BeaconScope, and it can pickup the beacons coming from both my devices even when I'm playing video on both devices.

AkshayNG commented 4 years ago

The two devices I have (Amazon FireHD tablet) and my samsung S9 don't have an issue. no special code needed, I switch to another app and the data still comes in.

In my test, the beacons are being detected in background for just few minutes (not more than 5 min.), this is due to restrictions laid by android from version 8.0+.

alann-maulana commented 4 years ago

I often use my Galaxy S10+ to broadcast iBeacon using packages beacon_broadcast along with my iPhone 6. There are no issue about iBeacon detection using this library.

Below is the exact code I'm using.

if(Platform.isAndroid) {
      beaconBroadcast.setLayout('m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24')
          .setManufacturerId(0x004C);
}
alann-maulana commented 3 years ago

With latest update flutter_beacon: 0.4.0 you can transmit as iBeacon too instead of scanning beacon only.