Logging Out
Confused about "Logging Out"?
Let us know how we can improve our documentation:
Last Edit:
Jan 18 2021
To disconnect a user (say that you’re for instance logging out and logging in as someone new) you can call the disconnect
method and repeat the connectUser
call as someone else:
client.disconnect();
client.connectUser(
{
id: 'jack',
name: 'Jack Doe',
},
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiamxhaGV5In0.OkDbpbujWJ-XIVHaf00Dnqt3v8Yp_nQ6CGzm-Z4QUVc',
);
client.disconnect();
Client.shared.disconnect()
// This disconnects the websocket connection but won't clear the Client.shard.user object
// To login as another user, you can call set(user:token:) as usual or setAnonymousUser() if using anonymous users
client.disconnect();
client.setUser(user, token, null);
await client.disconnect();
await client.setUser(otherUser, "{{ chat_user_token }}");
Disable Push Notifications
Additionally, you'll want to stop the user from receiving further push notifications by unregistering their device.