我的Xamarin.Android应用程序只在Android 11(Pixel 3 XL)上能收到推送通知。目前,我的应用程序针对Android 11进行了定位,但它也可以在Android 12(Pixel 6 Pro)上运行。唯一不起作用的是Firebase推送通知。以下是我正在使用的代码。在过去的一周中,我一直在研究这个问题,并看到有关Android 12(Pixel 6)无法接收推送通知的特定问题的帖子。我按照其他人建议的更改了手机配置,并且另一个应用程序的通知开始工作了,但是我的仍然没有。任何想法都会有所帮助。谢谢。
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);
}