We are migrating an old project to FCM V1 (We are late to the party i'm aware).
However we are running into some issues while using the test send from the azure portal.
We have reconfigured the notification hub SDK to create FCMV1 device registrations. We have deleted the old FCM/GCM API key from the configuration. We have configured the FCMV1 credentials based on the credentials from google cloud.
We have added the private key, project-id and client_email as a direct copy over from the json file we created in the google cloud console.
When sending a test message to a device we receive the following error: enter image description here
The firebase messaging API is enabled. However no requests have succeeded.
Any experience with this issue?
We were expecting the test send to succeed. However we are experiencing an invalid credential error, while the credential was directly provided by google cloud.
It turns out in our case that the file android/app/build/generated/res/google-services/values/values.xml contained another previously used project_id and was cached, so when registering the app with the token from that app, Firebase responds with mismatch sender id error to azure notification hub, that in turn just says authentication error.
Something to double check at least. How i got the actual error from Firebase:
using FirebaseAdmin;
using FirebaseAdmin.Messaging;
using Google.Apis.Auth.OAuth2;
CancellationTokenSource cts = new CancellationTokenSource();
var fapp = FirebaseApp.Create(new AppOptions()
{
Credential = await GoogleCredential.FromFileAsync("./your-credendials-file.json", cts.Token),
ProjectId = "yourproject",
ServiceAccountId = "<youraccount>"
});
var registrationToken = "token-from-client";
try
{
var result = await FirebaseMessaging.GetMessaging(fapp).SendAsync(
new Message()
{
Token = registrationToken,
Data = new Dictionary<string, string>()
{
{ "score", "850" },
{ "time", "2:45" },
}
}
);
}
catch(Exception e)
{
Console.WriteLine(e);
}