Unity-Technologies / com.unity.mobile.notifications

Mobile Notifications Package
https://docs.unity3d.com/Packages/com.unity.mobile.notifications@2.1/manual/index.html
Other
131 stars 42 forks source link

Android 12 Crash on UnityNotificationRestartOnBootReceiver #178

Closed asrakan closed 2 years ago

asrakan commented 2 years ago

We are having crashes that i suspects comes from: UnityNotificationRestartOnBootReceiver.onReceive PendingIntent get activity doesn't have the version code check with FLAG_MUTABLE flag. It does have in UnityNotificationManager.getActivityPendingIntent.

I will test the solution with editing UnityNotificationRestartOnBootReceiver.java for now but it would be better to have official fix.

• Project that reproduces the issue : Critical Strike: https://play.google.com/store/apps/details?id=com.critical.strike2 • Android • Notification Package version: 2.0.0 and enabled Reschedule on Device Restart. • Unity editor's version, that you are using 2019.4.36f1 • Mobile devices and their OS: Android 12 Devices

Fatal Exception: java.lang.RuntimeException Unable to start receiver com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver: java.lang.IllegalArgumentException: com.critical.strike2: 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.

Caused by java.lang.IllegalArgumentException: com.critical.strike2: 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:382) at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:465) at android.app.PendingIntent.getActivity(PendingIntent.java:451) at android.app.PendingIntent.getActivity(PendingIntent.java:415) at com.unity.androidnotifications.UnityNotificationRestartOnBootReceiver.onReceive(UnityNotificationRestartOnBootReceiver.java:41) at android.app.ActivityThread.handleReceiver(ActivityThread.java:4761) at android.app.ActivityThread.access$1800(ActivityThread.java:310) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2292) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8663) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Adnimistrator commented 2 years ago

This is duplicate to #160 and #161. It is closed and waiting to release in Notification Package version 2.0.1

aurimasc commented 2 years ago

Duplicate.