-
Notifications
You must be signed in to change notification settings - Fork 27
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
Battery doest not work when app in background #21
Comments
I had to fork it to add this. My fork hasn't been updated (I no longer use it in the background, as it was unreliable), but the commit in question is here: ascorbic@6d79ee3 |
@ascorbic It seems i cannot checkout to you commit (Maybe it was deleted. Error "Reference is not a tree"). So do you have better ideas what module to use to impement that feature - check battery level? |
You can’t checkout unless you’ve added mine as an upstream and `git
fetch`ed it. It’s a single line commented out though, so you may as well do
it yourself.
|
Thanks for opening this issue. Do we have any folks in this thread that are experienced with Android? I see in ascorbic@6d79ee3 you removed I assume not -- I put that in place because I saw a lot of prior art doing this. Happy to remove that if there's no consequences with keeping listeners active while the app is backgrounded. |
@ascorbic Yea. any bad effects if we remove |
@iadcg It didn't give the correct result if the app hadn't been launched since switching on. My use case was to detect if the device was on charge when running a background task, as it was running on single-use devices that were only supposed to sync while charging. |
I could see this as being configurable by the developer - we could provide a static setter which can be manually changed by developers who want to enable the library in the background: private static boolean runInBackground = false;
public static void setRunInBackground(boolean runInBackground) {
this.runInBackground = runInBackground;
} And then we could check for this value before the stop/resume lifecycle override methods. Ultimately I guess it's up to the developer to choose whether they want this in the background. Seems like we might want to keep the default as not running in the background, to avoid a queue of messages stacking up for the next time the app opens. |
Battery doest not work in android when app in background (minimized).
I have error:
Please fix it.
I use
"react-native": "0.54.4",
"react-native-background-task": "0.2.1"
some code:
The text was updated successfully, but these errors were encountered: