我已经尝试了好几天让FirebaseApp发送消息。请有人告诉我这里出了什么问题:
FirebaseApp app = FirebaseApp.Create(new AppOptions()
{
Credential =GoogleCredential.FromFile(HttpContext.Current.Server.MapPath("~\\Services\\Messaging\\MY_app-12345.json")).CreateScoped("https://www.googleapis.com/auth/firebase.messaging")
});
public static async Task SendAsync(string deviceRegId, string message)
{
FirebaseMessaging fbMessage = FirebaseMessaging.GetMessaging(app);
FirebaseAdmin.Messaging.Message m = new FirebaseAdmin.Messaging.Message
{
Token = deviceRegId,
Android = new AndroidConfig()
{
Notification = new AndroidNotification()
{
Body = message,
Title = "Title",
Sound = "bing"
},
Priority = Priority.Normal,
}
};
string response = await fbMessage.SendAsync(m);
Console.WriteLine("Successfully sent message: " + response);
}
永远不会越过fbMessage.SendAsyc并且应用程序永远不会收到消息。我看不到任何错误,什么也没有发生。谢谢!