Ionic native Social Sharing

Hello,

when updating my project to target version 32 the plugin ‘cordova-plugin-x-socialsharing’ has stopped working, it causes the app to close.

I get the following error:

java.lang.IllegalArgumentException:…..: 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.
        at android.app.PendingIntent.checkFlags(PendingIntent.java:408)
        at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:688)
        at android.app.PendingIntent.getBroadcast(PendingIntent.java:675)
        at nl.xservices.plugins.SocialSharing$2.run(SocialSharing.java:274)

any ideas?

thank you

Yeah, the plugin needs to be updated to support SDK v32. Here is the same issue - Android 12 issue · Issue #1201 · EddyVerbruggen/SocialSharing-PhoneGap-Plugin · GitHub

This line needs to be updated to include FLAG_IMMUTABLE or FLAG_MUTABLE.

Hi @twestrick,

Thanks for answering.

I change the file ‘…/plugins/cordova-plugin-x-socialsharing/src/android/nl/xservices/plugins/SocialSharing.java’ and I still get the same error.

Don’t change the file, update the plugin to the latest version (6.0.4) as it might have more requires changes.

2 Likes

Thank you @julio-ionic. That’s how it works for me