react-native-kontaktio icon indicating copy to clipboard operation
react-native-kontaktio copied to clipboard

Not working on Android 10 [Solved]

Open monickaalexander opened this issue 5 years ago • 7 comments

I tried to implement the minimal code on Android 10 device. I seems that the device is not able to add listeners as the DeviceEventEmitter.addlistener() is not working.

if(isAndroid) {
      console.log('enter listener')
      DeviceEventEmitter.addListener('beaconsDidUpdate', ({beacons, region}) => {
        console.log('checking places')
        for (i = 0; i < beacons.length; i++) {
          console.log('Beacons detected [major, rssi, uuid]---->', beacons[i].major, beacons[i].rssi, beacons[i].uuid);
      }});
  } 
else {
      kontaktEmitter.addListener('didRangeBeacons', ({beacons, region}) => {
        console.log('BeaconsinRange: ', beacons.length);
        for (i = 0; i < beacons.length; i++) {
          console.log('Beacons detected [major, rssi, uuid]---->', beacons[i].major, beacons[i].rssi, beacons[i].uuid);
        }
      });
  }
};

Is there any set up that needs to be done I am missing on? Thanks

monickaalexander avatar Oct 26 '20 17:10 monickaalexander

Facing same issue, any solution to this

AkaashK avatar Apr 25 '21 19:04 AkaashK

+1 - doesn't work on Android 10 or 11...

YCMitch avatar May 20 '21 12:05 YCMitch

Hello guys, As Android 10 has introduced the new requirement of permission, please request "ACCESS_FINE_LOCATION" instead of the "ACCESS_COARSE_LOCATION" in your code. I just made this change and it works on Android 10 and 11 devices again.

don't forget to add <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> into ApplicationManifest.xml file

Ref: https://altbeacon.github.io/android-beacon-library/requesting_permission.html

hl2000 avatar Aug 19 '21 01:08 hl2000

I already have ACCESS_FINE_LOCATION (and ACCESS_COARSE_LOCATION) in there, and it still doesn't work for Android 10/11. Do you think removing ACCESS_COARSE_LOCATION would help? Does yours have that too?

YCMitch avatar Aug 19 '21 02:08 YCMitch

In the latest Minimal Example(maybe updated since last year), I have replaced the "PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION" with "PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION", and it starts to work on Android 10 and 11 devices.

By the way, do you have <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> in your ApplicationManifest.xml file?

hl2000 avatar Aug 19 '21 02:08 hl2000

Yeah, that's already in there. I'll try removing ACCESS_COARSE_LOCATION perhaps, and see if it helps.

YCMitch avatar Aug 19 '21 03:08 YCMitch

Thanks @hl2000 for sharing this! Would you mind updating the Android docs and the Minimal Example to reflect this new requirement for Android 10+?

andrekovac avatar Aug 29 '21 09:08 andrekovac