[英]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.