簡體   English   中英

升級后 android 到 31 接收推送通知時應用程序崩潰 android 12 台或以上設備

[英]After upgrading android to 31 app crashes when receiving push notifications android 12 or above devices

將 android 升級到 31 后出現推送通知問題,在 android 12 或更高版本的設備上接收推送通知時應用程序崩潰

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] ' } }

實施 '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)


將庫更新到最新版本發行說明 OneSignal:flutter ,因為有從 Android 12 開始的新要求,如您在消息中所見:

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.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM