Leitfäden
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.
Auf dieser Seite
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
- Signed out, open the screen: the assistant runs an anonymous, guest session.
- Sign in inside your app and signal it: the same conversation becomes identified, with no reload.
- 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.
- Sign out: the next person to open the screen gets a guest session, not the previous customer's.
- Run
node v2/scripts/identity-conformance.mjs --host <your-host> --jsonfor whichever native platform your build targets — the WebView underneath is still iOS or Android, and the checker grades that layer.
Next
- Recognize signed-in customers — the four obligations this channel answers.
- In-app AI support for iOS and Android — the same wire messages from the native side.
- Fix a signed-in customer who shows as a guest — symptom-first fixes when a cell fails.
Fragen
Why one Dart file instead of separate iOS and Android code?
The
BusymateAINativechannel name is recognized bywebview_flutteron 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.