RealTimeX
Sign inStart for free
RealTimeXMobile Package
Introduction5-minute overviewFeaturesHow the package worksGlossary
Requirements & dependenciesBackend credentialsInstallation step by stepTutorial — your first chat appProject config fileApp entry — index.jsQuick start — minimum working chatComplete ChatScreen example
Native configuration (iOS & Android)Firebase, APNs & backend setup
Navigation — embedding the chatSession, auth & Socket.IOPermissions & access controlAudio & video callingPush notificationsMentions viewRich-text messages (WebView editor)Total unread count
Customization — four waysDefault component fallback (important)Which slots are wiredCustomization examples (Case 1–4)UI feature flags & copy (ui)Chat info (group + DM)Style overrides (ui.styles)Render props (ChatProvider)Theme, fonts & appearance
ChatProvider props referenceconfigureChat options referenceHooks & storeCallbacks referenceAPI query paramsAll exports
Production integration pattern (Fieldr)Host app integration — providers, toasts, tab bars & navigationEnvironment variablesLocal package / monorepo (Metro)
TroubleshootingSetup checklistArchitectureDocumentation & file mapPackage development (maintainers)License
Mobile packageFeatures & Guides

Session, auth & Socket.IO

You supply clientId + the host accessToken. The package:

  1. Restores a persisted chat session, or exchanges the host token for a chat token (bootstrapChatSession).
  2. Connects Socket.IO with the chat token (/connection path on socketUrl).
  3. 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

ExportPurpose
ensureChatSession(options?)Restore the persisted session, or bootstrap login + connect. Resets automatically if a different user (email) signs in
bootstrapChatSession(options?)Alias of ensureChatSession
connectChatSocket(chatToken, clientId?)Connect with an existing token (no-op when already authenticated)
logoutChatSession() / resetChatSession()Unregister push tokens, end any call, disconnect the socket, clear the persisted session (appearance kept)

options (BootstrapChatSessionOptions): { name?, email?, clientId?, hostAccessToken? }.

typescript
1import {bootstrapChatSession, logoutChatSession} from '@realtimexsco/live-chat-react-native';2 3// Host JWT without an email claim:4await bootstrapChatSession({email: user.email, name: user.name, hostAccessToken: token});5 6// On host logout — while the token is still valid (push tokens are deleted server-side):7await 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:

typescript
1configureChat({2  // …3  onSessionEnd: ({reason, message}) => {4    // reason: 'force_logout' | 'deactivated' | 'banned' | 'deleted' | 'workspace_deleted' | 'session_revoked'5    navigation.reset({index: 0, routes: [{name: 'Login'}]});6  },7});

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().

ExportPurpose
onChatSessionEnd(listener) → unsubscribeExtra listeners besides onSessionEnd
clearChatSessionEnd()Allow silent logins again
sessionEndReasonForCode(code), sessionEndMessage(reason)Map an error.code to a reason and its text

A NOT_A_PARTICIPANT refusal (you were removed from a conversation) drops that conversation from the list and closes it.

Socket API

typescript
1import {socketService, SOCKET_EVENTS} from '@realtimexsco/live-chat-react-native';2 3socketService.emitTypingStart({conversationId, userId}, isGroup);4 5const off = socketService.on(SOCKET_EVENTS.DM_RECEIVE, payload => {/* … */});6off();
socketService memberNotes
connected, isConnected(), getSocket()Connection state
connectWithSession(token, clientId)Preferred connect
ensureConnected()Reconnect with the last config
emit(event, payload?)Low-level emit (queued until connected)
on(event, handler) → unsubscribe, off(event, handler?)Listeners
emitDm* (send, edit, delete, reactions, pin / star, forward, clear, delete conversation)DM helpers
emitGroup* (join, send, edit, delete, reactions, pin / star, forward, mark read, leave, …)Group helpers
emitThreadReplySend, emitThreadTypingStart/Stop, emitThreadMarkReadThreads
emitTypingStart/Stop(payload, isGroup), emitMarkAsRead, emitGroupMarkReadTyping / receipts
disconnect(), reset()Tear down

SOCKET_EVENTS lists every chat event name (including session_revoked, thread_status_update, mention_created); CALL_SOCKET_EVENTS lists the call_* events.

PreviousNavigation — embedding the chatNextPermissions & access control

On this page

Session helpersServer-ended sessionsSocket API
Back to top