【问题标题】:Xamarin Forms error in background push notifications后台推送通知中的 Xamarin Forms 错误
【发布时间】:2022-11-08 18:44:46
【问题描述】:

我使用 firebase 在 Xamarin 表单中推送通知,在应用程序打开时工作正常,但在后台测试时我得到了扩展
定位 S+(版本 31 及更高版本)要求在创建 PendingIntent 时指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一。 强烈考虑使用 FLAG_IMMUTABLE,仅当某些功能依赖于 PendingIntent 是可变的时才使用 FLAG_MUTABLE,例如如果它需要与内联回复或气泡一起使用。

我搜索了这个错误并找到,应该安装Xamarin.AndroidX.Work.RuntimeNuget包,安装Xamarin.AndroidX.Work.Work.Runtime.KtxNuget 打包并安装Xamarin.Firebase.Analytics,我安装了它们但无法正常工作,仍然出现相同的异常。我该如何解决这个问题?

此日志数据

[AndroidRuntime] 致命异常:Firebase-PNFirebaseMessagingService [AndroidRuntime] 进程:com.raitotec.manaawateer,PID:2365 [AndroidRuntime] java.lang.IllegalArgumentException: com.raitotec.manaawateer:定位 S+(版本 31 及更高版本)需要 在创建时指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一 一个 PendingIntent。 [AndroidRuntime] 强烈考虑使用 FLAG_IMMUTABLE,仅在某些功能依赖于时才使用 FLAG_MUTABLE PendingIntent 是可变的,例如如果它需要与 内联回复或气泡。 [AndroidRuntime] 在 android.app.PendingIntent.checkFlags(PendingIntent.java:378) [AndroidRuntime] 在 android.app.PendingIntent.getActivityAsUser(PendingIntent.java:461) [AndroidRuntime] 在 android.app.PendingIntent.getActivity(PendingIntent.java:447) [AndroidRuntime] 在 android.app.PendingIntent.getActivity(PendingIntent.java:411) [AndroidRuntime] 在 com.google.firebase.messaging.zza.zzh(未知 来源:124) [AndroidRuntime] 在 com.google.firebase.messaging.FirebaseMessagingService.zzd(未知 来源:57) [AndroidRuntime] 在 com.google.firebase.iid.zzc.run(Unknown Source:2) [AndroidRuntime] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) [AndroidRuntime] 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) [AndroidRuntime] 在 com.google.android.gms.common.util.concurrent.zza.run(未知 来源:6) [AndroidRuntime] at java.lang.Thread.run(Thread.java:1012)

【问题讨论】:

    标签: android xamarin xamarin.forms xamarin.android


    【解决方案1】:

    您可以查看您的firebase插件的版本,可以通过升级Android Dependencies和Flutter插件来解决。

    或者你可以尝试添加这个依赖来解决:

    implementation 'androidx.work:work-runtime-ktx:2.7.1'
    

    【讨论】:

    • 我添加了 Xamarin.AndroidX.Work.Runtime.ktx 但没有任何帮助
    • 您是否尝试升级 Android Dependencies 和 Flutter 插件?
    • 我在 Xamarin 表单上工作,将插件更新到最新的稳定版本,但不起作用
    • 你能提供更详细的错误日志吗?
    • [FirebaseMessaging] 无法记录事件:缺少分析库 [AndroidRuntime] 致命异常:Firebase-PNFirebaseMessagingService [AndroidRuntime] 进程:com.raitotec.manaawateer,PID:29712 [AndroidRuntime] java.lang.IllegalArgumentException:com.raitotec.manaawateer:定位 S+(版本 31 及更高版本)要求在创建 PendingIntent 时指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一强烈考虑使用 FLAG_IMMUTABLE,如果某些功能依赖于 PendingIntent 是可变的,并且需要与内联回复或气泡一起使用,则仅使用 FLAG_MUTABLE。
    猜你喜欢
    • 2018-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-05
    • 2020-06-14
    • 1970-01-01
    • 1970-01-01
    • 2021-05-28
    相关资源
    最近更新 更多