katzer / cordova-plugin-background-mode

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

App crashes when enabling background mode on Android 12+ (target SDK level 31+) #585

Closed Mforcen closed 4 days ago

Mforcen commented 10 months ago

From Android 12 and newer, when trying to create a PendingIntent one of the following flags are required: FLAG_IMMUTABLE or FLAG_MUTABLE. The offending API call is located in the file ForegroundService.java:223.

Best regards.

Mforcen commented 10 months ago

I've fixed the PendingIntent crash in my fork: https://github.com/Mforcen/cordova-plugin-background-mode

Best regards.

jlherren commented 10 months ago

Thanks, this is actually really useful. The fork can be installed using

cordova plugin add 'https://github.com/Mforcen/cordova-plugin-background-mode#2b9a4de'
wuitoonchi commented 2 weeks ago

@Mforcen When you have time, it would be good if possible to upload or publish the plugin in npm so that it is available to the community, some time is usually wasted looking for how to solve the issue. I thank you very much in advance for your contribution.

Mforcen commented 2 weeks ago

@Mforcen When you have time, it would be good if possible to upload or publish the plugin in npm so that it is available to the community, some time is usually wasted looking for how to solve the issue. I thank you very much in advance for your contribution.

Yeah! Will do as soon as I get to my computer!

Mforcen commented 4 days ago

Hi @wuitoonchi, I've seen that there are already other versions of this plugin on NPM with the fix applied. Please use this, for example: https://www.npmjs.com/package/@andeo/cordova-plugin-background-mode