HatangChat
Entry point of the Hatang chat SDK. Call configure once (in Application.onCreate), then open the chat, identify the user and observe state / unreadCount / events.
HatangChat.configure(this, HatangConfig(siteId = "site_…", appKey = "hak_…"))
HatangChat.open(context)Properties
The configuration given to configure; throws when it has not run.
The production gateway.
The state machine (advanced hosts); throws when configure has not run.
Host-facing events: ready, opened, closed, messages, status, conversions, session changes, outdated.
configure has run.
The current session (visitor, conversation, locale).
Messages received while the chat was not on screen (for badges).
Functions
Unregisters the push token (sign-out).
Closes every chat screen opened by open, openInbox or handleNotification.
Configures the SDK. Calling it again replaces the previous instance (the old engine is disposed). With HatangConfig.autoConnect the SDK bootstraps and connects in the background right away.
Bootstraps and connects (after autoConnect = false or disconnect).
The conversation a Hatang notification points at, if any.
Closes the socket; the SDK stays configured.
Opens the conversation a Hatang notification points at (from the notification's tap, e.g. the launcher activity's intent extras). Returns false for foreign payloads. Starts the engine when it is not running yet (cold start).
Attaches the host user's identity. Pass a hash (HMAC-SHA256 of the user id with the site's identity secret, computed on your server) for verified identities. Throws HatangException on failure.
true when an FCM data payload came from Hatang (hatang: "1").
The restore token inside a magic link: /c/<token> paths or a hatang_restore query parameter; null otherwise.
Opens the chat screen in its own activity (the active conversation, or conversationId).
An intent that opens the chat (for a notification's PendingIntent).
The account id for one of your users: pass it as setObfuscatedAccountId when launching the Play billing flow so Google Play's notifications reach this customer in Hatang.
After a successful in-app purchase. With the Play purchaseToken Hatang verifies it with Google, records it for this person and acknowledges it (Play refunds unacknowledged purchases after three days). productType is "subs" or "inapp"; consumable marks one-time products used up in the app. The team also gets an internal note.
Restores the session behind a "we replied" magic-link token (see linkTokenFromUri).
Switches the language.
Registers the FCM token for this visitor. Safe before the SDK is ready: registration is deferred and repeated when the visitor or app version changes. Call it from FirebaseMessagingService.onNewToken and once at start-up with FirebaseMessaging.getInstance().token.
Shows a local-only assistant bubble (never sent to the gateway).