【问题标题】:After upgrading android to 31 app crashes when receiving push notifications android 12 or above devicesAfter upgrading android to 31 app crashes when receiving push notifications android 12 or above devices
【发布时间】:2022-12-27 21:18:26
【问题描述】:

I have a push notifications issue after upgrading android to 31, app crashes when receiving push notifications on android 12 or above devices

onesignal_flutter: ^2.6.4

buildscript { repositories { maven { url 'https://plugins.gradle.org/m2/'} } dependencies { classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.4, 0.99.99]' } }

implementation 'com.onesignal:OneSignal:3.13.1'

E/AndroidRuntime(22706):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:4480)
E/AndroidRuntime(22706):    at android.app.ActivityThread.access$1800(ActivityThread.java:277)
E/AndroidRuntime(22706):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2181)
E/AndroidRuntime(22706):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(22706):    at android.os.Looper.loopOnce(Looper.java:211)
E/AndroidRuntime(22706):    at android.os.Looper.loop(Looper.java:300)
E/AndroidRuntime(22706):    at android.app.ActivityThread.main(ActivityThread.java:8282)
E/AndroidRuntime(22706):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(22706):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576)
E/AndroidRuntime(22706):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1074)
E/AndroidRuntime(22706): Caused by: java.lang.IllegalArgumentException: com.myapp: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/AndroidRuntime(22706): 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.
E/AndroidRuntime(22706):    at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
E/AndroidRuntime(22706):    at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
E/AndroidRuntime(22706):    at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
E/AndroidRuntime(22706):    at com.onesignal.GenerateNotification.getNewActionPendingIntent(GenerateNotification.java:189)
E/AndroidRuntime(22706):    at com.onesignal.GenerateNotification.createGenericPendingIntentsForNotif(GenerateNotification.java:398)
E/AndroidRuntime(22706):    at com.onesignal.GenerateNotification.showNotification(GenerateNotification.java:382)
E/AndroidRuntime(22706):    at com.onesignal.GenerateNotification.fromJsonPayload(GenerateNotification.java:110)
E/AndroidRuntime(22706):    at com.onesignal.NotificationBundleProcessor.ProcessJobForDisplay(NotificationBundleProcessor.java:107)
E/AndroidRuntime(22706):    at com.onesignal.NotificationBundleProcessor.ProcessFromGCMIntentService(NotificationBundleProcessor.java:90)
E/AndroidRuntime(22706):    at com.onesignal.GcmBroadcastReceiver.startGCMService(GcmBroadcastReceiver.java:138)
E/AndroidRuntime(22706):    at com.onesignal.GcmBroadcastReceiver.processOrderBroadcast(GcmBroadcastReceiver.java:129)
E/AndroidRuntime(22706):    at com.onesignal.GcmBroadcastReceiver.onReceive(GcmBroadcastReceiver.java:70)
E/AndroidRuntime(22706):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:4467)


【问题讨论】:

    标签: android flutter onesignal


    【解决方案1】:

    Update the library to the last version release notes OneSignal: and flutter, because there are new requirements starting Android 12 as you can see in the message:

    E/AndroidRuntime(22706): Caused by: java.lang.IllegalArgumentException: com.myapp: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    E/AndroidRuntime(22706): 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.
    

    【讨论】:

      猜你喜欢
      • 2022-12-01
      • 2022-12-27
      • 1970-01-01
      • 2022-01-04
      • 2022-12-28
      • 2021-11-07
      • 2021-11-28
      • 2022-12-02
      • 1970-01-01
      相关资源
      最近更新 更多