【发布时间】:2022-01-25 21:41:44
【问题描述】:
我最近更新了我的应用程序以实现跨平台可用性,但我无法接收推送通知。
当我向后端发送“警报”时,应该通知用户有人发出了警报。
现在当我调用 SendFCMNativeNotificationsAsync 方法时,我总是得到排队响应(当我只有一个 Android 版本时,他们总是说成功)。
private async Task sendNotifAsync(Alert alert)
{
Microsoft.Azure.NotificationHubs.NotificationOutcome outcome = null;
HttpStatusCode ret = HttpStatusCode.InternalServerError;
var cafe = cafeRepository.GetById(alert.CafeId);
var message = alert.UserName + " needs help in " + cafe.Name;
var notif = "{ \"notification\":{\"title\":\"Somebody needs help\",\"body\":\""+message+"\"},\"data\" : {\"message\":\"" + "From " + alert.UserName + ": " + message + "\"}}";
outcome = await Notifications.Instance.Hub.SendFcmNativeNotificationAsync(notif);
}
这是我用来在后端调用notificationhub 的代码。
奇怪的是,当我尝试通过 firebase 控制台发送测试通知时,它按预期工作,所以我真的不知道现在去哪里解决这个问题。
【问题讨论】:
标签: flutter asp.net-core push-notification firebase-cloud-messaging azure-notificationhub