Darshana
Darshana

Reputation: 650

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

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.

Upvotes: 1

Views: 1207

Answers (2)

Alex Predescu
Alex Predescu

Reputation: 950

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

Upvotes: 0

Darshana
Darshana

Reputation: 650

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.

Upvotes: 0

Related Questions