가이드
Flutter에서 로그인한 고객 인식하기
loadRequest 전에 JavaScript 채널 하나를 등록하고, Dart 파일 하나를 복사한 후, 로그인, 로그아웃, 재개를 연결하기만 하면 됩니다. 플랫폼별 코드는 필요 없습니다.
이 페이지의 목차
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
- Signed out, open the screen: the mate 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 mate 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 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
- Recognize signed-in customers — the four obligations this channel answers.
- Native SDKs — 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.
질문
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 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.