Subscribe to push notifications times out

https://push-notification-us.cometchat.io/v1/subscribe?appToken={appToken} times out after :30 for me with no error message. Sending

{ "appId": "{appId}", "fcmToken": "{userFcmToken}", "topic": "{appId}_group_cardgroup-local-1" }

Any ideas?

Hello @eric

Here it seems that you are passing wrong fcmToken in the request, can you please verify the fcmToken and try again.

I changed my fcm server key and now I get “InvalidTokenVersion”. Not sure if that is referring to the fcmToken or the appToken.

Any update on this? I’m using v2 of the api, but the endpoint for subscribing/unsubscribing is v1 (https://push-notification-us.cometchat.io/v1/subscribe?appToken=…). Wondering if this is why I’m getting the InvalidTokenVersion error?

Hello @eric, the endpoint for push notification api is independent of chat api, can you please share me your app id, so that I can further investigate the same.

appId is 1101472abef83ba

thank you for your help.

Hi @eric,

The error response InvalidTokenVersion is from FCM and it is related to the device registration token/Instance ID token.

Since you are using the push-notification API to subscribe/unsubscribe, I’m assuming you are using JS based CometChat Pro SDK.

There is a possibility that the token is getting regenerated by FCM service. To keep the token updated, you need to use messaging.onTokenRefresh() callback and store the updated token in a variable or localStorage based on your implementation. The updated token can then be sent to push-notification API to subscribe/unsubscribe from a topic.

// Callback fired if token is updated.
messaging.onTokenRefresh(() => {
  messaging.getToken().then((refreshedToken) => {
    console.log('Token refreshed.')
    // update the token in localStorage.
  }).catch((err) => {
    console.log('Unable to retrieve refreshed token ', err);
  });
});

Since we are unable to reproduce this issue at our end, please try this and let us know if this resolves the issue.

1 Like

I got this working for device tokens. If I try a group token (which is what I have been trying), I get the InvalidTokenVersion error. Can you confirm if you support group tokens? If not, will you?

Hi Eric,

The subscribe and unsubscribe methods use device token. The push notification extension stores the device tokens mapped with UIDs and gives the extension complete flexibility to send message to a single or a group of device tokens.

It serves all the use-cases for chat and notification while keeping the implementation easy and simple even for new developers.

We are not supporting device group tokens and I do not see them fit to serve the purpose of CometChat push notification extension.

The current implementation uses a topic based approach for push notifications. With which developer need to keep on subscribing/unsubscribing a topic per group.

We are working on a strategy to keep it as simple as only two API calls subscribe and unsubscribe and everything else will be handled by CometChat and/or push notification extension.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.