コンテンツへスキップ
Busymate AI

このガイドは現在英語のみです。

ガイド

Flutterでサインイン済みの顧客を認識する

JavaScriptチャネルを1つloadRequest前に登録して、Dartファイルを1つコピーし、サインイン、サインアウト、再開をつなぐだけ — プラットフォーム固有のコードは不要です。

このページの内容

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.

Current: Sign-in and identity, Setup C.

1. Install the bridge before loadRequest

Call BusymateBridge.install(controller, BusymateBridgeConfig(assistant: ..., appId: ..., account: ..., mint: ...)) on your WebViewController before you call loadRequest: the same "before the page loads" rule every platform follows. account returns your user id or null; mint calls your own authenticated API with the request's nonce.

2. Copy the bridge file

Copy https://busymate.ai/sdk/v2/2.0.0/flutter/busymate_bridge.dart into your app (it needs webview_flutter, crypto and url_launcher). It answers the same operations every native bridge answers: identity, open an external link, and close the sheet. Load the hosted chat URL from Console › Integration with channel=android or channel=ios.

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. Try it with a fake sign-in first

Wire account to a switch before your real auth store. Confirm an anonymous chat, then an identified one when you flip it, before you connect your own auth store.

Verify

  1. Signed out, open the screen: the mate 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 mate 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 the Identity check for whichever native platform your build targets — the WebView underneath is still iOS or Android, and the checker grades that layer.

Next steps

よくある質問

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 mate'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 mate runs anonymously; wire the four obligations in whenever your endpoint is ready, and the channel starts answering on the next open.