Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I’m trying to implement push notifications by following the guide in the docs. I’ve encountered some issues/questions whilst doing.

In the section Upload Firebase Credentials under the dashboard section, this seems to be outdated? You can now access it via dashboard > Chat Messaging > Push Notifications instead of the description and images in the guide.

In the section Registering a device with Stream , it is unclear to me what the difference is between client.setLocalDevice and client.addDevice. I believe setLocalDevice was added for V2, but could someone explain the difference to me?

Thanks!

You must be logged in to vote

Prior to client.setLocalDevice, you would need to do two separate api calls:

await client.connectUser();
await client.addDevice();

But later we decided to make this more efficient, and merge these two api calls:

client.setLocalDevice(); // there is no api call here, we just store the device info in memory
await client.connectUser(); // pass the device info to backend

Replies: 1 comment · 2 replies

Comment options

Prior to client.setLocalDevice, you would need to do two separate api calls:

await client.connectUser();
await client.addDevice();

But later we decided to make this more efficient, and merge these two api calls:

client.setLocalDevice(); // there is no api call here, we just store the device info in memory
await client.connectUser(); // pass the device info to backend
You must be logged in to vote
2 replies
@VNDRN
Comment options

Ok, I get that, but why call client.addDevice after the user disconnects? It happens in the unsubscribeTokenRefreshListenerRef, which is called after client.disconnect?

And I could still use addDevice to add the device after the connection is already established?

@santhoshvai
Comment options

Hey @VNDRN

it is not done after user disconnecting.. but rather after token refreshing (this is done by firebase)

messaging().onTokenRefresh(async newToken => {
        await Promise.all([
          removeOldToken(),
          client.addDevice(newToken, push_provider, USER_ID, push_provider_name),
          AsyncStorage.setItem('@current_push_token', newToken),
        ]);
      });
    };

This method will return a subscription removal method, and that is stored inside unsubscribeTokenRefreshListenerRef

What we do in this method is to remove the stale token from the server and send the new token

I hope its clear now

Answer selected by santhoshvai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.