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

Crash: com.unity3d.player.g.onRequestPermissionsResult #244

Closed NickBogovich closed 1 year ago

NickBogovich commented 1 year ago

For only devices running Android 6 (and about 2/3 of them are Samsung), we are seeing this crash when targeting API 33 (13) with a minimum level of 22 (5.1):

Fatal Exception: java.lang.Error FATAL EXCEPTION [main] Unity version : 2021.3.14f1 Device model : ZTE BLADE V7 Device fingerprint: ZTE/P653A10_MX_TEL/P653A10:6.0/MRA58K/20160902.111813:user/release-keys Build Type : Release Scripting Backend : IL2CPP ABI : arm64-v8a Strip Engine Code : true

Caused by java.lang.RuntimeException Failure delivering result ResultInfo{who=@android:requestPermissions:android:fragment:2, request=96489, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {XXX.XXXXXXXX.XXXXXX/XXXXXX.MainActivity}: java.lang.IllegalArgumentException: Unknown permission: android.permission.POST_NOTIFICATIONS

android.app.ActivityThread.deliverResults (ActivityThread.java:3929) android.app.ActivityThread.handleSendResult (ActivityThread.java:3972) android.app.ActivityThread.access$1400 (ActivityThread.java:175) android.app.ActivityThread$H.handleMessage (ActivityThread.java:1537) android.os.Handler.dispatchMessage (Handler.java:111) android.os.Looper.loop (Looper.java:207) android.app.ActivityThread.main (ActivityThread.java:5728) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:789) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:679)

Caused by java.lang.IllegalArgumentException Unknown permission: android.permission.POST_NOTIFICATIONS android.os.Parcel.readException (Parcel.java:1603) android.os.Parcel.readException (Parcel.java:1552) android.content.pm.IPackageManager$Stub$Proxy.shouldShowRequestPermissionRationale (IPackageManager.java:2703) android.app.ApplicationPackageManager.shouldShowRequestPermissionRationale (ApplicationPackageManager.java:527) android.app.Activity.shouldShowRequestPermissionRationale (Activity.java:3904) com.unity3d.player.g.onRequestPermissionsResult android.app.Activity.dispatchRequestPermissionsResultToFragment (Activity.java:6635) android.app.Activity.dispatchActivityResult (Activity.java:6508) android.app.ActivityThread.deliverResults (ActivityThread.java:3925) android.app.ActivityThread.handleSendResult (ActivityThread.java:3972) android.app.ActivityThread.access$1400 (ActivityThread.java:175) android.app.ActivityThread$H.handleMessage (ActivityThread.java:1537) android.os.Handler.dispatchMessage (Handler.java:111) android.os.Looper.loop (Looper.java:207) android.app.ActivityThread.main (ActivityThread.java:5728) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:789) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:679)

We have confirmed that android.permission.POST_NOTIFICATIONS is indeed in our AndroidManifest.xml, and this permission works for all other flavors of Android outside of Android 6.

We are using v2.1.0 of com.unity.mobile.notifications.

NickBogovich commented 1 year ago

Thinking about it a bit more, I'm not exactly sure if this is caused within this package or at the Unity level itself.

AminSojoudi commented 1 year ago

RequestPermissions on Android is only for android 33 and above.

NickBogovich commented 1 year ago

Yes, said permission should only impact devices API level 33 and above, yet its presence is making some Android 6.0/6.0.1 (level 23) devices crash for whatever reason. It has zero issue with other Android versions.

aurimasc commented 1 year ago

How are you requesting for this permission? Do you use the API in the package, or Unity Permission class directly? The one in package should be checking for device API level and only request it when running on Android 13.

aurimasc commented 1 year ago

Closing since no reply.