Getting 'messaging/registration-token-not-registered' for newly created token

Viewed 16

Source code is based on FCM documentation

client.js:

const subscribe = () => {
    return getToken(getMessaging(), {vapidKey: 'vapidKey'}) // -> always same token
        .then(token => {
            return subscribeToTopic(token);
        });
}

const subscribeToTopic = async (token) => {
    const subscribe = httpsCallable(functions, "subscribeToTopicNotifications");
    return subscribe({
        token: token
    });
}

Firebase function:

export const subscribeToTopicNotifications = functions.https.onCall(async (data, context) => {
    const subscriptionToken = data.token;
    firebase.messaging().subscribeToTopic(subscriptionToken, topic).then(subscriptionResult => {
      // ERROR: 'messaging/registration-token-not-registered'
    });
}

Error explanation from Firebase docs (https://firebase.google.com/docs/cloud-messaging/send-message?hl=en#admin):

messaging/registration-token-not-registered The provided registration token is not registered. A previously valid registration token can be unregistered for a variety of reasons, including:

  • The client app unregistered itself from FCM.
  • The client app was automatically unregistered. This can happen if the user uninstalls the application or, on Apple platforms, if the APNs Feedback Service reported the APNs token as invalid.
  • The registration token expired. For example, Google might decide to refresh registration tokens or the APNs token may have expired for Apple devices.
  • The client app was updated, but the new version is not configured to receive messages.

For all these cases, remove this registration token and stop using it to send messages.

Error is the same for subscribeToTopic and unsubscribeFromTopic.

Does anyone know: What it means to "remove this registration token and stop using it"? How to generate new token, when getToken returns same token every time?

0 Answers
Related