The registration token is not a valid FCM registration token

Aperta
#363 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
csharp, firebase

Direzione di ricerca

Inizia con FirebaseMessaging.DefaultInstance.SendAllAsync nel codice .NET segnalato ed esamina la riproduzione PushNotificationPoC collegata. Confronta l’origine del token e la configurazione del progetto Firebase con il comportamento segnalato; il lavoro è completato quando la discrepanza viene riprodotta e viene documentata una causa o una correzione confermata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

needs-triage

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);

}

BatchResponse response = default;
try
{
response = await FirebaseMessaging.DefaultInstance.SendAllAsync(messages);

// Check for a successful response
if (response != null)
{
    Console.WriteLine("Successfully sent message: " + response);
}
else
{
    Console.WriteLine("FCM response is null.");
}

}
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

image

But same token I am sending using firebase console it is working fine

[REQUIRED] Step 2: Describe your environment
  • Operating System version: Android 11
  • Firebase AdminSDK version: 2.4.0
  • Firebase Product: Push Notification
  • .NET version: .net core 7
  • OS: windows 11
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
  1. Create Xamarin forms application.
  2. Setup firebase Push notification plugin and android manifest.
  3. Get Token from refresh token if in debug or else token
  4. try to send Push Notification using Token.
  5. here you will get error
Relevant Code:

https://github.com/jitendrajadav/PushNotificationPoC

Lingua principale
C#
Stelle
407
Fork
147
Merge medio
2g 10h
PR unite (30g)
12

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di firebase/firebase-admin-dotnet

Tutte le issue di firebase/firebase-admin-dotnet

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.