'Firebase token from the device showing as invalid instance when calling it from the backend server

I'm getting the token from the firebase using the client end and passing it to the server/backend for storage, but when I call subscribe to topic using that firebase token on the server, I'm getting

{"error":"No information found about this instance id."}.

This happens almost all the time, but sometimes it works, I don't seem to understand what is happening here?



Solution 1:[1]

I started receiving this message in a response with 404 as the status code when the client unregistered from push notifications on the client side (when he/she did logout, for example, I unregister the user from receiving push notifications in the app). The next time the client logged in, he/she received a new registration token.

I don't know if and when your app unregisters from push notifications, and if this is the only case in which such response errors happen, but that was the reason in my case, and it could be yours too.

When I try to subscribe/unsubscribe from topics and receive 404 when accessing https://iid.googleapis.com/iid/[...], I simply invalidate the respective registration id in my codebase so as to ignore it (and stop trying to subscribe or unsubscribe again).

In the documentation, in the final section that is about Error Responses, it says:

HTTP status 404 (Not found) - Invalid HTTP path or IID token not found. Check error messages for detailed information.

I'm pretty much sure that the url must be valid, otherwise it should give errors when testing, so I assume that the token (registration id) is invalid. I would prefer that the error returned a code such as InvalidRegistration (like the error codes that are returned when sending push notifications), but for now the error is a normal text message (for the 404 error), so I base myself only in the status.

I hope it helps.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1