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

ionic background mode not working when phone is unplug in android 10+ #570

Open
YSoni89 opened this issue Aug 4, 2022 · 0 comments
Open

Comments

@YSoni89
Copy link

YSoni89 commented Aug 4, 2022

I am trying to use this plugin for one of my use case. I need to run some processes in background when app (built in ionic 5 and angular 10) is minimize and screen is locked. I am using Samsung X cover Android 10 + version. Its working fine for longer period of time (approx. 14-15 hours) if I plugin my phone (USB cable charging on), minimize the App with screen lock but it does not give similar results if I unplug the phone from charger. App stop the background processes after 2-3 hours.

Can you please advice here?

Below is the code implemented ->

On device platform ready => below code is written
this.background.setDefaults();
this.background.enable();
this.background.on('activate').subscribe(() => {
this.background.disableWebViewOptimizations();
this.background.disableBatteryOptimizations();
});

I tried using "cordova-plugin-power-optimization": "0.0.4" => this.powerOptimization.RequestOptimizations();
this.powerOptimization.IsIgnoringBatteryOptimizations();
along with above options.

Permissions are set in my AndroidManifest.xml file such as -
android.permission.WAKE_LOCK,
android.permission.FOREGROUND_SERVICE
android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS

Using latest versions of backgroundmode plugin - "cordova-plugin-background-mode": "^0.7.3",

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

1 participant