Open 3Danix opened 2 years ago
@3Danix Found the solution for this? We are facing the same issue with API level 31
unfortunately no, the only option is to change notification plugins.
Il giorno lun 14 nov 2022 alle 19:19 Dinesh-Glu @.***> ha scritto:
@3Danix https://github.com/3Danix Found the solution for this? We are facing the same issue with API level 31
— Reply to this email directly, view it on GitHub https://github.com/universal-tools/UTNotificationsFeedback/issues/139#issuecomment-1314189368, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2NOYFVQF4UZ6LJ7ID4Q4T3WIJ7EHANCNFSM554JIL5Q . You are receiving this because you were mentioned.Message ID: @.***>
I found a workaround for this bug. It is caused by a new requirement of Android 12 (API level 31):
https://developers.google.com/ar/develop/unity-arf/android-12-build https://developer.android.com/about/versions/12/behavior-changes-12#exported
It requires that all activities, services and broadcast receivers that use intent filters must explicitly declare the exported attribute in the Android manifest.
To make this work with UTNotifications, you must patch a couple of manifest files.
In these files, add android:exported="true" to the service tag.
Unfortunately, there is another missing flag in the manifest of utnotifications.aar (located under Plugins/Android). To fix this, you have to add the flag to the AndroidManifest.xml in this folder:
Since this is only the source file, you also have to re-compile the Android .aar file yourself. To do this, open AndroidStudio and then point it to the NativePluginSource folder:
If you use custom Gradle templates, you will also have to set the android:exported flag to the main activity.
In my case (Unity 2019), I also had to download gradle-6.1.1 and set this as a custom gradle in the External Tools section of Unity preferences.
I found a workaround for this bug. It is caused by a new requirement of Android 12 (API level 31):
https://developers.google.com/ar/develop/unity-arf/android-12-build https://developer.android.com/about/versions/12/behavior-changes-12#exported
It requires that all activities, services and broadcast receivers that use intent filters must explicitly declare the exported attribute in the Android manifest.
To make this work with UTNotifications, you must patch a couple of manifest files.
* Plugins/UTNotificationsRes/AndriodManifest.xml * UTNotifications/Editor/Android/FCMRes/Android.xml
In these files, add android:exported="true" to the service tag.
Unfortunately, there is another missing flag in the manifest of utnotifications.aar (located under Plugins/Android). To fix this, you have to add the flag to the AndroidManifest.xml in this folder:
* UTNotifications/Editor/Android/NativePluginSource/utnotifications/src/main
Since this is only the source file, you also have to re-compile the Android .aar file yourself. To do this, open AndroidStudio and then point it to the NativePluginSource folder:
* Open "Resource Manager" tab on the left side * Switch the Build Variant of the :utnotifications module to "release" * Run "Build > Make Project" * Use Finder or Explorer to go the build folder (sub-folder of NativePluginSource) * You will find utnotifications-release.aar in build/outputs/aar * Rename the file to utnotifications.aar and place it under Plugins/Android
If you use custom Gradle templates, you will also have to set the android:exported flag to the main activity.
In my case (Unity 2019), I also had to download gradle-6.1.1 and set this as a custom gradle in the External Tools section of Unity preferences.
This is unique solution for me that work. 3 days were wasted and 30 mins for this solution and it work. Thank you so much! The only thing I had to do to compile new aar file. Reboot PC (because Unity folder was locked maybe by Unity) and run Android Studio as admin. After that Android Studio could download needed resources... Thank you again!
Glad I could help.
Hello,
we have recently updated our app to api 32 (android 12), we have a significant increase in crashes due to the notification tool
below the report from Android Vital
Exception java.lang.RuntimeException: at android.app.ActivityThread.handleReceiver (ActivityThread.java:4770) 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 at com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run (RuntimeInit.java:567) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1135) Caused by java.lang.IllegalArgumentException: at android.app.PendingIntent.checkFlags (PendingIntent.java:382) at android.app.PendingIntent.getBroadcastAsUser (PendingIntent.java:673) at android.app.PendingIntent.getBroadcast (PendingIntent.java:660) at universal.tools.notifications.Manager.buildPendingIntentForScheduledNotification (Manager.java:768) at universal.tools.notifications.Manager.scheduleNotificationCommon (Manager.java:651) at universal.tools.notifications.ScheduledNotificationsRestorer.restoreScheduledNotification (ScheduledNotificationsRestorer.java:67) at universal.tools.notifications.ScheduledNotificationsRestorer.restoreScheduledNotifications (ScheduledNotificationsRestorer.java:59) at universal.tools.notifications.ScheduledNotificationsRestorer.onReceive (ScheduledNotificationsRestorer.java:76) at android.app.ActivityThread.handleReceiver (ActivityThread.java:4761)
How can we solve?