Driversnote-Dev / react-native-kontaktio

React Native (iOS and Android) library for Kontakt.io beacons (and all other beacons)
MIT License
112 stars 48 forks source link

Android Beacon detection is not working when App close. #53

Closed kiritm-nimblechapps closed 4 years ago

kiritm-nimblechapps commented 5 years ago

Hi,

I have set region and start scanning in android. it's work fine when app in foreground. The data of beacon getting the results. but when App is closed, And after I checked the beacon is not connect.

Can you help me what is mistake in android.

Thanks.

ginixsan commented 5 years ago

Anybody did manage to make it work for region monitoring when app is closed?

andrekovac commented 5 years ago

You probably have to use an Android Foreground Service. Take a look at this package: https://github.com/voximplant/react-native-foreground-service . I didn't yet try it myself though. Please report here if it solves the issue! I would then add this info to the README.

Btw, how does your definition of closed relate to the appstate? When you observe the AppState is the app state background?

NielsOtten commented 4 years ago

Thanks @Andruschenko, this seems to work fine! When using a foreground service the beacons scanner seems to keep working.

NielsOtten commented 4 years ago

There still seems to be a problem with detecting beacons in the background on android 8.1 >. When your screen is turned off no beacons are updated. This seems to be a bug in the Kontakt SDK. I have made an issue for Kontakt (#201).

unkindypie commented 4 years ago

@nylsoo did you find the solution of this problem? I am currently facing the same issue using react-native-beacons-manager and the same foreground service as you.

unkindypie commented 4 years ago

@nylsoo nevermind. I figured out by myself. Just updated version of altbeacons to the latest. react-native-beacons-manager from npm for some reason uses old build from 2017. Installing from their github repository directly will fix this issue.

izaa commented 4 years ago

@unkindypie Hi, could you tell what version the react-native-beacons-manager exactly should use and where do you change the version? Thanks :)

unkindypie commented 4 years ago

@izaa just use npm install https://git@github.com/MacKentoch/react-native-beacons-manager to install the package from the latest commit at master. But I should say that it works perfectly on android >=8.1 including background, but for some reason stops detecting beacons on android <8.1. I tried some older commits from that repository and faced the same problem. If you find a solution, please share it.

izaa commented 4 years ago

@unkindypie ah ok! Yes I've tried that, but looks that this kontaktio works better than that manger. How do you feel which one is better?

unkindypie commented 4 years ago

@izaa in my opinion currenly both of them are bad for android. I have created an issue on react-native-beacons-manager, maybe someday someone will help us.

izaa commented 4 years ago

@unkindypie thanks for the info! So both work better in iOS? I haven't tried yet iOS.

NielsOtten commented 4 years ago

I am currently contacting Kontakt to see if they could do something about this issue. They seem to be unresponsive on their own Github page.

NielsOtten commented 4 years ago

Got in contact with the Kontakt support desk and it seems this issue won't be fixed any time soon due to lack of mobile developers... They recommended using another library like Alt Beacon.

Their response: Hi ...., Unfortunately as of right now, we can not assure that this feature will be implemented in the Android SDK. It has been noted but it will not be implemented in the near future because of the availability of our mobile developers. Solution, for now, would be using foreground services in Android and some other libraries that fit your needs as you mentioned before. I hope you understand Best regards,

dmontecillo commented 2 years ago

Hello @unkindypie I am having issues with react-native-beacon-manager with react-native-background-actions when app is in background it receives empty beacons. Please advise how to fix issue? Thanks

unkindypie commented 2 years ago

Hello @unkindypie I am having issues with react-native-beacon-manager with react-native-background-actions when app is in background it receives empty beacons. Please advise how to fix issue? Thanks

Unfortunately I can't say you an exact answer(it's been 2y ago) but most likely it has something to do with permissions on background geo location. You can try requesting them and check is it detecting anything. And it's still a workaround, it's possible that after 2y there may be a better solution