FCM HTTP V1 API returns 404 for unregistered token

The FCM HTTP v1 API should return an "UNRect" error code when the device is not registered (the application has been removed). However, the API returns 404 "The requested object was not found."

Has anyone experienced this? Is this expected? This is not mentioned anywhere in the documentation.

Can the device be considered unregistered if error 404 with the message "Required object not found"?

Below is the full text of the error received.

{ "error": { "code": 404, "message": "Requested entity was not found.", "errors": [ { "message": "Requested entity was not found.", "domain": "global", "reason": "notFound" } ], "status": "NOT_FOUND" } } 

An exception:

 Caused by: com.google.firebase.messaging.FirebaseMessagingException: Requested entity was not found. at com.google.firebase.messaging.FirebaseMessaging.handleSendHttpError(FirebaseMessaging.java:266) ~[firebase-admin-5.9.0.jar:?] 

For API reference documentation:

https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode

+13
source share
2 answers

Yes, I tested this with the firebase-admin-node module, which was recently updated to match NOT_FOUND with an “unregistered” error, so this seems to be the expected answer.

https://github.com/firebase/firebase-admin-node/commit/069c9cd50502b0fa7cc6843ea3ef9d8d85dca9b9#diff-ce3edf3ab3ed8957259b6bd4035a0256R617

(Although it seems that the NOT_FOUND status is key information, not the message "The requested object was not found")

One thing you can confirm is unregistered tokens from different browsers / devices. That is, I think that unregistered tokens from chrome return a different error than one of firefox.

+9
source

We encounter an error code 404 when sending notifications to Unregistered devices through the old FCM endpoint:

 https://fcm.googleapis.com/fcm/send 

The documentation for API v1 has been updated and does not contain this error code.

0
source

Source: https://habr.com/ru/post/1275518/


All Articles