Session, auth & Socket.IO
You supply clientId + the host accessToken. The package:
- Restores a persisted chat session, or exchanges the host token for a chat token (
bootstrapChatSession). - Connects Socket.IO with the chat token (
/connectionpath onsocketUrl). - Owns emit / listen for DMs, groups, threads, typing, receipts, calls and notifications. Emits made before the socket connects are queued and flushed on connect;
on()listeners registered early are attached when the socket is created.
Session helpers
options (BootstrapChatSessionOptions): { name?, email?, clientId?, hostAccessToken? }.
import {bootstrapChatSession, logoutChatSession} from '@realtimexsco/live-chat-react-native'; // Host JWT without an email claim:await bootstrapChatSession({email: user.email, name: user.name, hostAccessToken: token}); // On host logout — while the token is still valid (push tokens are deleted server-side):await logoutChatSession();Server-ended sessions
A workspace admin can force a logout, deactivate or ban a user, or delete the user or the whole workspace. The server then sends session_revoked, refuses the socket handshake, or answers REST with 401 SESSION_REVOKED / 403 ACCOUNT_DEACTIVATED / 403 ACCOUNT_BANNED / 403 WORKSPACE_DELETED. In every case the package stops reconnecting, clears its session (tokens, cached user, push registration), shows a short toast and calls onSessionEnd:
configureChat({ // … onSessionEnd: ({reason, message}) => { // reason: 'force_logout' | 'deactivated' | 'banned' | 'deleted' | 'workspace_deleted' | 'session_revoked' navigation.reset({index: 0, routes: [{name: 'Login'}]}); },});Silent logins (bootstrapChatSession, auto-connect, token refresh) for the same host token and email stay blocked afterwards, even across restarts, so the auto-bootstrap can't undo a force logout. They resume after a new token or a different user, an explicit authActions.loginRequest(...), or clearChatSessionEnd().
A NOT_A_PARTICIPANT refusal (you were removed from a conversation) drops that conversation from the list and closes it.
Socket API
import {socketService, SOCKET_EVENTS} from '@realtimexsco/live-chat-react-native'; socketService.emitTypingStart({conversationId, userId}, isGroup); const off = socketService.on(SOCKET_EVENTS.DM_RECEIVE, payload => {/* … */});off();SOCKET_EVENTS lists every chat event name (including session_revoked, thread_status_update, mention_created); CALL_SOCKET_EVENTS lists the call_* events.