c# - 在 ASP.NET Core 中使用 firebase 发送通知
问题描述
我有一个 ASP.NET Core 应用程序,它将使用 Firebase 发送一些通知。
我正在使用此代码通过 C# 发送通知消息。
启动.cs
public IServiceProvider ConfigureServices(IServiceCollection services)
{
//...
FirebaseApp.Create(new AppOptions()
{
Credential = GoogleCredential.FromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "key.json")),
});
//...
}
这是我如何发送通知的代码
try
{
string ServerKey = "MY_SERVER_KEY";
var message = new Message()
{
Notification = new Notification
{
Title = "Message Title",
Body = "Message Body"
},
Token = ServerKey,
};
return await FirebaseMessaging.DefaultInstance.SendAsync(message);
}
catch(Exception ex)
{
return null;
}
问题是在我运行我的函数发送通知后,我收到以下错误:
SenderId 不匹配
我检查了文档和其他一些我没有找到如何放置发件人 ID 的地方。
解决方案
推荐阅读
- rest - 在 Golang 中发出 HTTP 请求非法路径
- python - 向后 Dijkstra 算法
- sql-server - 性能——检查没有行还是只执行*多个*更新语句?
- java - Java函数式编程随机整数流数学abs不起作用
- python - 设置选项时,Tkinter 按钮抛出“未知选项 -XXXXX”。蟒蛇 2.7
- c# - 我可以在没有等待和异步的情况下使用 Task.Run 吗?
- node.js - req.body 在 express.js 应用程序中未定义(路径正确,使用正文解析器,正文具有键和值)但 req.body 未定义
- ffmpeg - FFmpeg api,如何将没有 pts 时间戳的原始 h264 复用到 mp4 或 m3u8
- algorithm - 有没有其他解释为什么“卢恩算法”很好?
- sql - 如何合并 SQL Server 中具有映射到通用描述的不同列标题的表?