Answers for "firebase remove not valid token"

0

firebase remove not valid token

admin.messaging().sendToDevice(tokens, payload).then((response) => {
  // For each message check if there was an error.
  const tokensToRemove = [];
  response.results.forEach((result, index) => {
    const error = result.error;
    if (error) {
      console.error('Failure sending notification to', tokens[index], error);
      // Cleanup the tokens who are not registered anymore.
      if (error.code === 'messaging/invalid-registration-token' ||
          error.code === 'messaging/registration-token-not-registered') {
        // TODO: remove the token from your registry/database
      }
    }
  });
});
Posted by: Guest on December-01-2020

Code answers related to "firebase remove not valid token"

Code answers related to "Javascript"

Browse Popular Code Answers by Language