-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Background Mode is running for only 5 min in Android 9 #430
Comments
Are you sure that you are using the latest git version of the plugin and you have enabled the plugin inside |
Yes I have enabled that inside platform.ready block and i have latest git version. |
+1 |
+1 |
+1. Anybody have any solution? |
+1 |
I founded the solution at #434 |
I tried this solution and it did not work, to continue running beyond the 5 minutes I had to go to settings -> battery -> battery optimization and check to not optimize my application. |
@rafaelgalle this is great. I see that there is already the functionality in this plugin (not released on npm yet) to disable battery optimization in the code. Did anybody use this already? |
@tobika Outputs the following message: I'm install plugin How can I use it? |
@MyoungboKim are you using the ionic native wrapper You should be able to enable this function without the wrapper like so :
|
I just saw in this commit that we have to add the permissions on our own: a966905#diff-53f390d375398624afe1cfe1125f42bf any special reasons for this @katzer ? (by the way, thanks for this amazing plugin :) )
|
@tobika |
I have installed the latest background mode plugin, but I got error when I build: why this happens? My code is:
background mode plugin version is:
|
@n1705771 |
@MyoungboKim still got build error:
[14:57:42] ionic-app-script task: "build" Code is like:
background mode plugin version is:
|
@n1705771 |
@MyoungboKim Thanks. I successfully build it following your direction. But the plug-in seems doesn't solve the problem. Still running for only 5 min if without power cable plugged. Does it work for you? |
@n1705771 your final code looks alright, you get the console.log at the end? did you add Maybe this makes a difference? I haven't had the 5min problem yet because my app is constantly streaming music which seems to keep it alive. Just general info: Keep in mind that the @ionic-native bindings are not up to date with the github plugin version. |
@tobika
and find the background mode error:
The new code is as below, I declare the var cordova as a global variable at the lower limit of "import", build was succeeded.
|
@n1705771 can you tell me which version of @ionic-native you are using? the .on is not correct About your other error, I don't have this one but I see you found the existing issue about it. |
@tobika great thanks! Can you tell me how to check the version?
Then I got the result as:
So, I think version is 5.4.0 |
@n1705771 ok, but as I said ths version is a bit incorrect which will result in your event not being called. |
@tobika I deleted background-mode plugin in folders of node_modules and plugins, also removed the background-mode info from package.json and package-lock.json. Then, install the latest plugin again. After that, the version became:
I have checked the
It is:
I rebuild the program, but still have the same error:
|
I fixed about issue as the solution given in #431. Now I see console log:
But still issue exists! I set 1 min interval for app to upload some data to server, the app only works well if the external power is supplied to my android phone (connect power cable to phone with external power source). My code is:
|
@n1705771 if not covered by the above. |
Thanks. I removed the plugin and re-installed the latest plugin. For my Huawei Mate 10, after turning off the power save mode in battery setting, it works! Seems this issue also related to different brands of phone manufactures. (#400), I am curious if there is a way can automatically set the power save mode off when once the application is opened? |
I installed https://github.com/lkonzen-garupa/cordova-plugin-background-mode And in plugin.xml is already this:
and add the code for wake_lock, Working in android 5, 7, 10 :-) |
Battery optimization issue fix: katzer#430 (comment)
my hpone is honor10 android9,this plugin didnot work ~~~who can help me,thanks! |
I have a P20 Mate Pro, and it stops a background upload after 60 minutes. I tried this with 3 programs all doing some GPS tracking and they all stopped at exactly the same time. It's like the phone just like to deep sleep for no reason. |
With no upload / download or GPS magic in action, but with a continuous ble connection on Android 10 it does its job well if you follow the approach in "Quirks" section:
But why does performance decrease (application resource usage increases, especially CPU) triply? How could this be explained? |
you can call the wakeUp method at a given time.
|
@katzer , Can you please advice here? Below is the code implemented -> On device platform ready => below code is written I tried using this.powerOptimization.RequestOptimizations(); Permissions are set in my AndroidManifest.xml file such as - |
This plugin is working for Android 8+ and older but not properly working for Android 9.
When I am connecting Sensor to my application in android 9 after 5 min in background application not getting data and again start sending data after reopening the application.
I think the plugin is not updated for android 9 power management updates.
https://developer.android.com/about/versions/pie/android-9.0-changes-all
Android Version - 9
Ionic Version - 9
The text was updated successfully, but these errors were encountered: