Skip to main content

hailbell 1.2.1 copy "hailbell: ^1.2.1" to clipboard
hailbell: ^1.2.1 copied to clipboard

In-app support chat and push notifications for Flutter apps, using Hailbell's native SDKs on iOS and Android and its web widget on the web.

Hailbell for Flutter #

In-app support chat and push notifications from Hailbell for Flutter apps on iOS, Android and the web.

On iOS and Android the plugin wraps Hailbell's native SDKs. Your customers get the same native chat as Swift and Kotlin apps: ticks, typing, photos, review and offer cards, an offline cache, and the chat's words in 14 languages. On Flutter web it loads Hailbell's web widget, with the same Dart API (see Web). You answer from the Hailbell dashboard, Discord or Telegram.

When the support AI hands a chat to your team while nobody is around, the chat shows a reply time card saying when to expect a reply, in the customer's own time, with a button to turn on notifications. The card arrived in 1.1.2; earlier versions show the same words as a normal message.

import 'package:hailbell/hailbell.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Hailbell.configure(appId: 'app_...');   // the App ID of the platform the app runs on
  runApp(const YourApp());
}

// A "Chat with us" button
onPressed: () => Hailbell.open(),

The step-by-step setup, including push with firebase_messaging, is in GUIDE.md. The example app is in example/.

Edited and deleted replies #

Your team can edit or delete a reply after sending it (dashboard). The chat shows the new wording, with "Edited" under it when the customer had already read the old one, and "This message was deleted" in place of a deleted reply, in the customer's language. Both arrived in 1.1.3; earlier versions show the new wording without the label, and a deleted reply as that line in English. Nothing to set up.

Requirements #

  • Flutter 3.27 or later.
  • iOS 16 or later. Swift Package Manager and CocoaPods both work.
  • Android 7 (API 24) or later, Kotlin 2.0 or later.
  • Web: any browser the Hailbell web widget supports. Desktop (macOS, Windows, Linux) isn't supported.

Hailbell #

API Use
Hailbell.configure(appId:, baseUrl:) Call once at launch, after WidgetsFlutterBinding.ensureInitialized(). iOS, Android and the web have different App IDs.
Hailbell.open() Opens the chat as a full-height sheet. Throws a StateError before configure.
Hailbell.unreadCount A ValueListenable<int> of replies not yet read, for a badge. unreadCountStream is the same as a Stream<int>.
Hailbell.identify(userId:, name:, email:, identityToken:) Who the user is. Only identityToken, an HS256 JWT signed with the app's identity secret, links the chat across devices.
Hailbell.identify(name:, email:, firebaseIdToken:) For apps on Firebase Auth: a function returning the current ID token. Hailbell verifies it and uses the Firebase uid as the user id.
Hailbell.setMetadata(map) Context shown beside the chat, merged with what you sent before. appVersion, os and locale are sent automatically.
Hailbell.track(event, properties:) A signal shown beside the chat, such as paywall_decline or chat_opened.
Hailbell.setPaywallPlacements(list) The placements an offer can open.
Hailbell.onPaywall (placement, purchased) {}: open the paywall, and call purchased() if they buy.
Hailbell.setPushToken(token) Android: the FCM token. iOS: the plugin takes the APNs token by itself; pass getAPNSToken() only as a fallback, never the FCM token.
Hailbell.handleNotification(data) Opens the chat for a tapped reply's payload. The plugin already does this for its own notifications.
Hailbell.darkMode null (default) follows the phone. Set true for an always-dark app.
Hailbell.asksForNotifications Default true: after the first message, the chat offers to turn on notifications if they're off.
Hailbell.setTeamPhoto(bytes) Deprecated: set the photo in the dashboard. A bundled photo shows only until the chat hears from Hailbell, and never once the dashboard signs replies as the team, turns photos off or sets a photo for this app.
Hailbell.shakeToReport Default false. When true, shaking the phone opens the bug report screen.
Hailbell.trackScreen(name) Notes the screen the user is on. A bug report carries the last 10.
Hailbell.reportBug() Opens the bug report screen, for a "Report a problem" button.
Hailbell.log(line) 1.1.0. Keeps a line for the next bug report. The last 50 stay in memory on the phone.
Hailbell.logRequest(method:, url:, status:) 1.1.0. Records a failed request (status 400 or more, or no answer). A bug report carries the last 10: method, address, status and time, never bodies or headers.
Hailbell.reset() On sign-out: clears the identity and the cached chat.
Hailbell.deleteData() Deletes the user's chat, images and details from Hailbell. Throws a HailbellException if the server can't be reached.

HailbellPush #

API Use
handleMessage(data, title:, body:) Pass every firebase_messaging message, from onMessage and onBackgroundMessage. Returns false for messages that aren't Hailbell's.
isHailbell(data) True when an FCM data map came from Hailbell.
requestPermission(provisional:) Asks for notification permission and registers for pushes.
canNotify() Whether the user allows notifications.
setTags(map) Key/value data for segments; a null value removes a tag.
setMarketing(enabled) / optOut() Promotional opt-in, or stop all Hailbell pushes to this device.
onOpen iOS: route a tapped campaign push yourself; return true when handled. On Android the link opens as an intent for your app.
clearBadge(appGroup:) iOS: resets the badge kept by the Notification Service Extension.
setAndroidOffersChannel(id) Android: use the app's own channel for campaign pushes. Call before configure.

Web #

Since 1.1.1 the plugin also runs on Flutter web. Hailbell.configure adds Hailbell's web widget (https://api.hailbell.com/widget.js) to the page, without its round chat button, and the same calls drive it. Give the app a Web platform in the dashboard and pass its App ID on the web:

import 'package:flutter/foundation.dart';

await Hailbell.configure(
  appId: kIsWeb ? 'app_WEB_XXXXXXXX' : (defaultTargetPlatform == TargetPlatform.iOS ? 'app_IOS_XXXXXXXX' : 'app_ANDROID_XXXXXXXX'),
);
  • Works the same: configure, open (the widget's chat panel), identify (identity token or firebaseIdToken), setMetadata, track, unreadCount and unreadCountStream, onPaywall (offer cards), darkMode, reset and deleteData. configure returns at once; the other calls wait until the widget has loaded.
  • Do nothing on the web: setPushToken, setPaywallPlacements, trackScreen, reportBug, log, logRequest, shakeToReport, asksForNotifications, setTeamPhoto, and HailbellPush's setTags, setMarketing, optOut, onOpen, clearBadge and setAndroidOffersChannel. handleNotification, HailbellPush.requestPermission and HailbellPush.canNotify return false. They are safe to call, so shared code needs no kIsWeb checks.
  • Same customer on phone and browser: sign the user in with the same identity token or Firebase account as in your phone app, so the dashboard has one user id for both, with their purchases and offers.
  • Browser push isn't part of the plugin. Add hailbell-push.js to web/index.html as the web docs describe.
  • If the page has a Content Security Policy, allow https://api.hailbell.com in script-src, style-src and connect-src, and wss://api.hailbell.com in connect-src. If the script can't load (blocked or offline), the plugin logs a warning in the browser console and the calls do nothing.
  • If web/index.html already has the widget's script tag, the plugin uses that widget instead of adding a second one.

Install #

flutter pub add hailbell

or in pubspec.yaml:

dependencies:
  hailbell: ^1.1.1

How it's built #

lib/ is the Dart API. It talks to android/ and ios/ over one method channel, hailbell, and an event channel, hailbell/unread_count, for the unread count. On the web, lib/src/hailbell_web.dart answers the same channels by calling the web widget's JavaScript API.

The plugin carries Hailbell's iOS and Android SDKs inside it, in ios/hailbell/Sources/hailbell/Vendor/ and android/vendor/hailbell/, so each release pins one version of both. Those folders are replaced on every release; don't edit them. The plugin's own native code is ios/hailbell/Sources/hailbell/HailbellPlugin.swift and android/src/main/kotlin/com/hailbell/flutter/.

flutter test runs the Dart tests against a mocked channel. flutter test --platform chrome test/hailbell_web_test.dart runs the web plugin against a fake widget in Chrome.

Support and license #

Questions: [email protected], or the chat on hailbell.com.

MIT. See LICENSE.

0
likes
160
points
1.13k
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

In-app support chat and push notifications for Flutter apps, using Hailbell's native SDKs on iOS and Android and its web widget on the web.

Homepage
Repository (GitHub)
View/report issues

Topics

#chat #support #push-notifications #customer-support

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, web

More

Packages that depend on hailbell

Packages that implement hailbell