Android 12 未收到 Firebase 推送通知

Firebase Push notification not receiving on Android 12

我的 Xamarin.Android 应用的推送通知仅适用于 Android 11 (Pixel 3 XL)。目前我的应用程序针对 Android 11,但它也可以在 Android 12 (Pixel 6 Pro) 上运行。唯一不起作用的是 Firebase 推送通知。下面是我正在使用的代码。在过去的一周里,我一直在研究这个问题,并看到了关于 Android 12 (Pixel 6) 未收到推送通知的特定问题的帖子。我对其他人建议的 phone 配置进行了更改,并且另一个应用程序通知开始工作,但我的仍然没有。任何想法都会 help.Thanks.

 if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
            {
                // Notification channels are new in API 26 (and not a part of the
                // support library). There is no need to create a notification
                // channel on older versions of Android.


                var name = "NameOfChannel";
                var description = "Notification Channel";
                var channel = new NotificationChannel(CHANNEL_ID, name, NotificationImportance.Max)
                {
                    Description = description
                };

                var notificationManager = (NotificationManager)GetSystemService(NotificationService);
                notificationManager.CreateNotificationChannel(channel);

            }       

找到解决方案。这是在 AndroidManifest 中的 Firebase 服务标签上添加 android:exported="false"

我错过的是

PendingIntent.FLAG_IMMUTABLE

如果 Notification 具有 pendingIntent,则为其设置 mutable/immutable Flag