Closed ghost closed 2 years ago
Hi @charlesrostaing, Thanks so much for bringing this to our attention!
The README code sample on how to detect & remove expired / unregistered device tokens could be improved by ensuring we only flag device tokens which FCM labels NotRegistered
as unregistered.
I've gone forth and updated the code sample in the README in commit https://github.com/ToothlessGear/node-gcm/commit/924a4f8c2117d1bb21e0b2b7ef05878f556d3e98:
var failed_tokens = registrationTokens.filter((token, i) => response.results[i].error === 'NotRegistered');
This is the only error code for which FCM recommends removing the token from the app server, and avoiding sending any additional notifications to it.
For a full list of possible FCM errors, please review the FCM downstream message error response codes: https://firebase.google.com/docs/cloud-messaging/http-server-ref#error-codes
In the example given in the Readme, it filters the tokens based on
response.results[index].error != null
in order to delete those. But not all errored tokens should be deleted. Some might have failed once but could still be valid for later ?Is there a list of possible options for the field
error
?