Skip to content
Busymate AI

Ce guide est actuellement en anglais.

Guides

Recognize signed-in customers in Flutter

Register the BusymateAINative JavaScript channel before loadRequest, copy one Dart file, and wire sign-in, sign-out and resume — no per-platform code.

Sur cette page

Busymate AI recognizes a Flutter app through one JavaScript channel your WebView plugin already knows how to register — no bridge code to write yourself, only a channel name and a small Dart file to wire in before the page loads.

1. Register the channel before loadRequest

Name it exactly BusymateAINative; that name already carries the shape the assistant probes for on launch. Register it — and its compatibility twin, both named in the sample below — on your WebViewController before you call loadRequest, the same "before the page loads" rule every platform in this kit follows.

2. Copy the identity file

Copy https://busymate.ai/sdk/v1/kit/flutter/busymate_identity.dart into your app. It answers the same three messages every native bridge answers: an identity request, an open-url request for external links, and a close request for the sheet.

3. Wire the four obligations

Your channel handler calls your own authenticated API for a fresh { token, nonce } pair on every identity request — never a cached one. Call the bridge's sign-in signal on login, token rotation and account switch; its sign-out signal on logout; and its resume signal from your widget's didChangeAppLifecycleState when the app returns to the foreground. A signed-out answer is null, never a stale pair.

4. Run the sample first

https://busymate.ai/sdk/v1/kit/flutter/sample.dart is a working screen with a fake sign-in switch and the channel already registered. Confirm it behaves — an anonymous chat, then an identified one on the fake sign-in — before you connect your own auth store.

Verify

  1. Signed out, open the screen: the assistant runs an anonymous, guest session.
  2. Sign in inside your app and signal it: the same conversation becomes identified, with no reload.
  3. Put the app in the background past the token's lifetime, then bring it forward: the assistant re-asks and is answered fresh, not refused as stale.
  4. Sign out: the next person to open the screen gets a guest session, not the previous customer's.
  5. Run node v2/scripts/identity-conformance.mjs --host <your-host> --json for whichever native platform your build targets — the WebView underneath is still iOS or Android, and the checker grades that layer.

Next

Questions

Why one Dart file instead of separate iOS and Android code?

The BusymateAINative channel name is recognized by webview_flutter on both platforms' underlying WebViews, so registering it once covers the same bridge shape on either OS.

What is the "compatibility twin" the sample also registers?

An older channel name kept for apps that shipped before this vocabulary existed; the sample registers both so neither generation of the assistant's probe goes unanswered.

Does my Flutter app need cookies configured for this to work?

No. Identity arrives from your own channel handler on every ask, so no cookie or WebView storage setting has any bearing on whether a customer is recognized.

Can I ship the chat before my API can mint identity yet?

Yes. Without a signed answer the assistant runs anonymously; wire the four obligations in whenever your endpoint is ready, and the channel starts answering on the next open.