Ionic: Background mode does not work in Android 12 with API level 31

911 views Asked by At

I have an Ionic 5 app with Audio player which allows user's to play audio even if the app is in background using Ionic Background mode plugin.

Above requirement works fine in API level 30. But after using API level 31, Ionic Background mode plugin doesn't work in Android 12.

Can any one please suggest me to solve this issue.

2

There are 2 answers

0
Darshana On

Since background mode is not working for Android 12 with API level 31 for now, I have solved this issue by using powerOptimization.RequestOptimizations() before enabling Background mode.

0
Alex Predescu On

Check out this issue on the plugin repo: https://github.com/katzer/cordova-plugin-background-mode/issues/576

The problem with Android 12+ was solved by the author with just a few code changes. You can reinstall the cordova-plugin-background-mode plugin from the fork: https://github.com/alindzon/cordova-plugin-background-mode