Node
Select your Platform:
Client SDKs
Backend SDKs
Logging Out
Confused about "Logging Out"?
Let us know how we can improve our documentation:
LAST EDIT Apr 08 2021
- On This Page:
- Disable Push Notifications
To disconnect a user (say that you’re for instance logging out and logging in as someone new) you can call the disconnectUser
method and repeat the connectUser
call as someone else:
1
2
3
4
5
6
7
8
await client.disconnectUser();
await client.connectUser(
{
id: 'jack',
name: 'Jack Doe',
},
'CHAT_USER_TOKEN',
);
1
2
client.disconnect();
client.connectUser(user, token).enqueue(result -> { /* ... */ });
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import StreamChat
// It's impossible to log out a user because the Client instance must always have a user assigned.
// However, you can simulate this behavior by A: destroying the client instance, or:
// B: Setting the current user as anonymous
chatClient.tokenProvider = .anonymous
chatClient.currentUserController().reloadUserIfNeeded()
// C: Disconnecting the client
chatClient.connectionController().disconnect()
// when you want to reconnect
chatClient.connectionController().connect { error in
if error == nil {
// connection successful
}
}
1
2
client.disconnect()
client.connectUser(user, token).enqueue { /* ... */ }
1
2
3
await client.disconnect();
await client.setUser(otherUser, "{{ chat_user_token }}");
Disable Push Notifications
Copied!Confused about "Disable Push Notifications"?
Let us know how we can improve our documentation:
Additionally, you'll want to stop the user from receiving further push notifications by unregistering their device.