You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I trying to send push notification through web APi .net core 7 where I have installed FirebaseAdmin Nuget packages version 2.4.0 and my configuration is
// Get the current directory and append the relative path to the JSON file var serviceAccountKeyPath = System.IO.Path.Combine(Environment.CurrentDirectory, "serviceAccountKey.json"); // Initialize the default app var defaultApp = FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromFile(serviceAccountKeyPath), });
and I am sending message like below snippet
`var messages = new List();
foreach (var item in tokens.Split(','))
{
string trimmedToken = item.Trim();
// Create a message
var message = new Message
{
Notification = new Notification
{
Title = model.Title,
Body = model.Message,
},
Token = trimmedToken, // The device token of the recipient
};
messages.Add(message);
// Check for a successful response
if (response != null)
{
Console.WriteLine("Successfully sent message: " + response);
}
else
{
Console.WriteLine("FCM response is null.");
}
I trying to send push notification through web APi .net core 7 where I have installed FirebaseAdmin Nuget packages version 2.4.0 and my configuration is
// Get the current directory and append the relative path to the JSON file var serviceAccountKeyPath = System.IO.Path.Combine(Environment.CurrentDirectory, "serviceAccountKey.json"); // Initialize the default app var defaultApp = FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromFile(serviceAccountKeyPath), });
and I am sending message like below snippet
`var messages = new List();
foreach (var item in tokens.Split(','))
{
string trimmedToken = item.Trim();
}
BatchResponse response = default;
try
{
response = await FirebaseMessaging.DefaultInstance.SendAllAsync(messages);
}
catch (FirebaseException ex)
{
Console.WriteLine("Error sending FCM message: " + ex.Message);
Console.WriteLine("Error code: " + ex.ErrorCode);
// Handle the error appropriately
}`
I am getting error saying
The registration token is not a valid FCM registration token
But same token I am sending using firebase console it is working fine
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
Relevant Code:
https://github.com/jitendrajadav/PushNotificationPoC
The text was updated successfully, but these errors were encountered: