I managed tu successfully send a FCM test message from Firebase console. However, when I try to send it from a console app using this code, I get an exception like:
"The registration token is not a valid FCM registration token":
public async static Task<string> SendByExample()
{
try
{
string credential_path = @"C:\IIII\XXXXXy\adminsdk.json";
var app = FirebaseApp.Create(new AppOptions
{
ProjectId = "posmobxxx",
Credential = GoogleCredential.FromFile(credential_path)
}, "App name");
var message = new Message
{
Data = new Dictionary<string, string>
{
{ "additional_data", "a string" },
{ "another_data", "another string" }
},
// the notification itself
Notification = new Notification
{
Title = "a title",
Body = "a body",
ImageUrl = "link"
},
Token = "eYF7xxaLSbu0Zxxxx0bUO24lr:APxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
};
var firebaseMessagingInstance = FirebaseMessaging.GetMessaging(app);
var response = await firebaseMessagingInstance.SendAsync(message).ConfigureAwait(false);
return response;
}
catch (AggregateException ae)
{
string errors = "";
foreach (Exception ex in ae.InnerExceptions)
{
errors += ex.Message + " " + System.Environment.NewLine;
}
return errors;
}
}
The device token is the same as the one that I use for sending test message from Firebase console.