onebear_chat

Flutter SDK for the OneBear live-chat widget. Wraps the native Android sdk/android OneBearChat SDK behind a Flutter platform channel, so a customer app can embed the same OneBear agent-console conversation as every other channel (LINE, Facebook, Instagram, WhatsApp, Email, TikTok, Lazada, Shopee).

Status: Android only in this release — see the design spec at docs/superpowers/specs/2026-08-31-mobile-chat-sdk-design.md for the full mobile SDK architecture (iOS and the underlying native shells land in a later release).

Getting started

dependencies:
  onebear_chat:
    git:
      url: https://github.com/GofiveCorp/Onebear.git
      path: sdk/flutter

Usage

import 'package:onebear_chat/onebear_chat.dart';

// Once, on app start — apiBaseUrl is the OneBear API origin.
await OnebearChat.configure(
  publicKey: 'pk_live_...',
  apiBaseUrl: 'https://app.onebear.example',
);

// Optional — identify a logged-in user. userHash MUST be computed by YOUR backend
// (HMAC of userId with your widget's secret) — never compute it in the app.
await OnebearChat.identify(
  const OnebearIdentity(userId: 'u_123', userHash: 'server_computed_hash'),
);

// Badge your own UI — there is no built-in floating launcher on mobile.
OnebearChat.unreadCount.listen((count) {
  // update a tab badge, etc.
});

// Open the chat full-screen from wherever your app's "Support" entry point is.
await OnebearChat.present();

// Call on sign-out — erases session, visitor token, unread count, and pending messages so
// the next person on a shared device never sees the previous user's conversation.
await OnebearChat.logout();

Events

OnebearChat.events.listen((event) {
  switch (event) {
    case ChatOpened():
    case ChatClosed():
    case NewMessageReceived():
      break;
    case LinkTapped(:final url):
      // The native SDK already opens agent-sent links in Custom Tabs — this is
      // informational, not a request to handle it yourself.
      break;
    case ErrorOccurred(:final message):
      break;
  }
});

Known limitations (v1)

  • Android only (minSdk 24). iOS is out of scope for this release.
  • Attachment upload requires a session-token bridge frame that does not exist yet — see docs/superpowers/plans/2026-09-01-mobile-sdk-2-android.md Task 8's notes. Core chat (configure/identify/present/logout/unreadCount/events) is unaffected.

Troubleshooting

Build fails with com.google.common.base.VerifyException in mergeDebugJavaResource / mergeReleaseJavaResource

This is an Android Gradle Plugin bug in its zip-packing code (apkzlib's MsDosDateTimeUtils.packDate), triggered when the build machine's system locale is Thai (th_TH) — the JVM's default Calendar under that locale uses the Thai Buddhist Era, which throws off AGP's date packing and fails the build with no useful message. This is unrelated to this package's code and can affect any Android build on an affected machine, not just one that depends on onebear_chat.

Fix: add this to your app's android/gradle.properties:

org.gradle.jvmargs=-Duser.language=en -Duser.country=US

(append to your existing org.gradle.jvmargs line rather than replacing it if you already have one). Then stop any running Gradle daemon (cd android && ./gradlew --stop) before rebuilding — an already-running daemon keeps its original JVM locale until it's restarted.