Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FCM HTTP V1 API returns 404 for unregistered token

Tags:

FCM HTTP v1 API supposed to return error code "UNREGISTERED" when device is unregistered (app uninstalled). However API returns 404 "Requested entity was not found".

Have anyone experienced this? Is this the expected one? There is no mention about this anywhere in the documentation.

Is it safe to assume device is unregistered when 404 error with the message "Requested entity was not found" received?

Following is the full body 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"   } } 

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 reference API documentation:

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

like image 882
yottabrain Avatar asked Feb 22 '18 13:02

yottabrain


2 Answers

Yes, I've experienced this with the firebase-admin-node module, which has been updated recently to map NOT_FOUND to an "unregistered" error, so it appears that it is an expected response.

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

(Though it looks to be the status being NOT_FOUND is the key info rather than the "Requested entity was not found" message)

One thing you may want to confirm is unregistered tokens from different browsers/devices. I.e., I think unregistered tokens from chrome returned a different error than one from firefox.

like image 120
dule Avatar answered Sep 18 '22 13:09

dule


We face error 404 error code when sending notifications to Unregistered Devices via the old FCM endpoint:

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

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

like image 23
Willem Avatar answered Sep 17 '22 13:09

Willem