parse-community / Parse-SDK-Android

The Android SDK for Parse Platform
https://parseplatform.org/
Other
1.88k stars 739 forks source link

Android12 raises a Exception with onPushReceive #1137

Closed junya100 closed 2 years ago

junya100 commented 2 years ago

New Issue Checklist

Issue Description

 The following exception is raised with Android12 when onPushReceive is called.
 And targetSDKVersion is 31.

 Caused by: java.lang.IllegalArgumentException: my.package: 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:375)
    at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
    at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
    at com.parse.ParsePushBroadcastReceiver.getNotification(ParsePushBroadcastReceiver.java:430)
    at com.parse.ParsePushBroadcastReceiver.onPushReceive(ParsePushBroadcastReceiver.java:168)

Steps to reproduce

Call ParsePushBroadcastReceiver#onPushReceive method.

Actual Outcome

Caused by: java.lang.IllegalArgumentException: my.package: 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:375) at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645) at android.app.PendingIntent.getBroadcast(PendingIntent.java:632) at com.parse.ParsePushBroadcastReceiver.getNotification(ParsePushBroadcastReceiver.java:430) at com.parse.ParsePushBroadcastReceiver.onPushReceive(ParsePushBroadcastReceiver.java:168)

Expected Outcome

No exception.

Environment

any Parse Android SDK version with Android12 and targetSDKVersion 31

Parse Android SDK

Logs

parse-github-assistant[bot] commented 2 years ago

Thanks for opening this issue!

azlekov commented 2 years ago

According to the docs Android 12 enforce mutability flag for each pending intents. I will check this and open a PR.

parseplatformorg commented 2 years ago

🎉 This change has been released in version 2.0.6

parse-github-assistant[bot] commented 2 years ago

The label state:released cannot be used in combination with state:needs-investigation.