[英]Notification Not Received on Android Device in Xamarin Android
实际上,我尝试通过控制台中的“测试设备”选项发送单个设备的通知。 它显示已完成但设备未收到通知。 然后我尝试了 postman 和 pushtry.com,他们都给出了结果“Firebase 推送通知发送成功”,即使没有收到 android 设备(谷歌像素版本 9)。 请帮我解决这个问题。
您的 MainActivity 中可能没有通知通道,您可以将其配置如下:
void CreateNotificationChannel()
{
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.
return;
}
var channel = new NotificationChannel(CHANNEL_ID, "FCM Notifications", NotificationImportance.Default)
{
Description = "Firebase Cloud Messages appear in this channel"
};
var notificationManager = (NotificationManager) GetSystemService(NotificationService);
notificationManager.CreateNotificationChannel(channel);
}
然后从 MainActivity 的 OnCreate 方法中调用
最小化您的应用程序(例如转到仪表板或锁定手机)并发送 FCM 推送通知。 如果您在这种情况下能够收到通知,则表示您的 FCM 配置正确。 您共享的代码仅在您在后台应用时才有效。 如果您希望在应用程序处于后台时收到通知。 您必须实现继承 FireBaseMessagingService 调用并覆盖 OnMessageRecived 方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.