Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate background services / tasks on Android #39

Closed
piuholo opened this issue Jun 14, 2017 · 3 comments
Closed

Investigate background services / tasks on Android #39

piuholo opened this issue Jun 14, 2017 · 3 comments
Assignees

Comments

@piuholo
Copy link
Contributor

piuholo commented Jun 14, 2017

Currently the behaviour of the app varies between iOS and Android if the app is on background, inactive or killed.
This is especially the case with bluetooth monitoring/ranging and receiving push notifications while the phone is locked.

Android version could potentially benefit from running background tasks.

See resources:

https://facebook.github.io/react-native/docs/headless-js-android.html

https://github.com/vikeri/react-native-background-job

https://github.com/devfd/react-native-workers

@0is1
Copy link
Contributor

0is1 commented Jun 15, 2017

@0is1 0is1 self-assigned this Jun 20, 2017
@0is1
Copy link
Contributor

0is1 commented Jun 28, 2017

background-beacons branch includes now quite well working implementation for Android. Biggest issue is maybe backgroundSchedule -> period that isn't running like defined with all Android versions. But reliability is still quite okay.

We also need to do extra ranging in there, see: http://github.com/HSLdevcom/react-native-proto/blob/e24edbd5ef29a9f5964498b0d7ae6b7885246ddc/index.js#L68-L89 but it seems that only Android 5.x is acting like that.

@0is1
Copy link
Contributor

0is1 commented Jun 30, 2017

Android background task is now merged to master, see androidBackgroundJob-function: http://github.com/HSLdevcom/react-native-proto/blob/0801ab727848501185b20529f1cb42d1bf27c560/index.js#L69-L104

The point is to start monitoring if there is regionDidExit / regionDidEnter event listener. If not add the event listeners, start monitoring and also start ranging. There's logic to stop the ranging (vehicle beacons at the moment) if phone doesn't see any beacons in 20 seconds.

Main problem at the moment is that Android 6 and 7 doesn't stop ranging (even if the phone is sleeping) if there is beacon in range and your phone battery will be empty quite quickly.

@0is1 0is1 closed this as completed Jul 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants