firebase/quickstart-js

Firebase Cloud Messaging token sometimes invalid

Opened this issue · 0 comments

Step 1: Describe your environment

  • Operating system: Android/Windows
  • Browser: MSEdge/Chrome
  • Firebase SDK version: firebase_messaging: ^14.7.10 / firebase_core: ^2.24.2

Step 2: Describe the problem:

I have restful backend app with auth system, where when user log-in,
backend will validate the fcm by fetch with POST method to https://fcm.googleapis.com/fcm/send
With payload like this:
{ "registration_ids": [ "fcm_token..." ] }

The problem is, sometime it return failure status 1 on first check, but on second/third check, it return succes status 1.

image

Steps to reproduce:

  1. Get the fcm token from android app (flutter)
  2. Fetch with POST method to https://fcm.googleapis.com/fcm/send with payload: { "registration_ids": [ "fcm_token..." ] } (with backend or postman, doesn't matter)
  3. Randomly return failure status: 1

Observed Results:

I have no idea why is this happen, but mostly happen on first validate (when the token is not validated for a while).
It also happen when I spam fetch it, it give a failure result around 1/10.

Expected Results:

Not return failure status=1 because the token is still valid

Relevant Code:

-