Skip to main content

Mobile apps

Customers can chat with you from inside your own app. The native SDKs open a chat screen in the app, keep the conversation in sync and receive push notifications. Their messages land in the same inbox as your website visitors. This page explains how the dashboard side works; the SDK pages cover the code.

How an app connects​

A mobile app is attached to a website (a site) in Support → Channels. It shares that site's settings, such as office hours and the AI assistant, and its conversations belong to that site for reports, distribution rules and automation.

Browsers prove where they come from with their Origin, which must match the site's domain or allowed origins. An app has no origin, so it sends an app key instead:

  • Each app gets its own key, which starts with hak_. You pass it to the SDK together with the site id.
  • The key ships inside your app, like the site id. It is scoped to one site and you can revoke it, so treat it as public but not as something to spread around.
  • A key never gives access to your data or the REST API. Server calls use API keys (Authentication).

Create an app key​

  1. Go to Support → Channels → Add channel → Mobile app.

  2. If the business has several sites, pick the website the app belongs to under Attach new connections to site.

  3. Fill in the form:

    FieldNotes
    App nameFor you, for example Moc Huong iOS
    PlatformiOS, Android, Flutter, React Native or Other
    Bundle ID / package (optional)One per line, for example com.example.app. A reminder only; it is not enforced yet
  4. Click Create app key. The key is shown once on the next page, next to an Initialise the SDK snippet. Copy it into your app's configuration.

You can also open a website in Support → Channels, switch to its Apps tab and click Add app.

Configure the SDK​

Every SDK takes the same two values: the site id (site_...) and the app key (hak_...). For example, in Flutter:

await HatangChat.configure(
siteId: "site_...",
appKey: "hak_...",
);

Follow the guide for your platform: Flutter, iOS, Android or React Native. The SDK overview lists every SDK with its supported versions.

Two topics apply to every app:

  • Identify signed-in users so the same person sees the same history on the web and in the app: Identity verification.
  • Push notifications go through your own Firebase project. Upload its service account once per website, in the website's Apps tab under Push notifications (Firebase); the key is shared by every app of that site. See Push notifications.

The app's page​

Each app has its own page under Support → Channels. It shows the platform, bundle IDs, the start of the key, when it was created, when the app last connected and how many devices are registered for push. Its status is Not used yet until the app connects for the first time, then Active, and Off once the key is revoked.

Revoke or replace a key​

Click Revoke on the app's page when a key leaks or a build should stop connecting. Within about a minute every install that uses the key is refused with app_key_revoked (HTTP 403), and the SDK cannot start a new session until you ship a build with a new key. To rotate:

  1. Create a new app key (a second app for the same website).
  2. Release a build that uses it.
  3. Revoke the old key once few users still run the old build, then Delete it.
caution

Revoking cuts off every install that still uses the key, including people who have not updated your app. Release the new build first.

Troubleshooting​

SymptomCauseFix
invalid_app_key (401)The key is mistyped or belongs to another siteCopy the site id and the key from the same website
app_key_revoked (403)The key was revokedShip a build with a new key
product_disabled (403)The Support module is offAn owner or admin turns it on (Modules)
The app stays Not used yetThe app has not bootstrapped with this key yetRun the app and open the chat once; check the SDK logs
No push notificationsNo Firebase service account on the website, or the device did not registerUpload the service account in the Apps tab; check Push notifications

Next steps​

View this page as Markdown