katzer / cordova-plugin-background-mode

Keep app running in background
Apache License 2.0
1.38k stars 1k forks source link

Background mode gives Error Targeting S+ (version 31 and above) on android #577

Closed INARTECHSA closed 1 year ago

INARTECHSA commented 1 year ago

Im trying to use background mode with my Ionic 6 app but it gives me this error: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. I’ve tried adding implementation 'androidx.work:work-runtime:2.7.1' to the gradle dependencies but no result. Any ideas on how to resolve this? Thanks!

alindzon commented 1 year ago

There are multiple forks documented under issues and pull requests that address this. Seems no one is maintaining this version anymore.

for example.

https://github.com/katzer/cordova-plugin-background-mode/issues/576

INARTECHSA commented 1 year ago

I fixed it by manually opening the ForegroundService.java file under the folder de.appplant.cordova.plugin.background and around line 225 I changed the PendingIntent.FLAG_UPDATE_CURRENT to PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_MUTABLE

mauro81pzm commented 9 months ago

I fixed it by manually opening the ForegroundService.java file under the folder de.appplant.cordova.plugin.background and around line 225 I changed the PendingIntent.FLAG_UPDATE_CURRENT to PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_MUTABLE

I love you :-) you saved my from going crazy