Add in-app support to a Flutter app

Give your Flutter app a "Get help" button that shares your app's screen with your support team on iOS and Android, with consent, under your company's name.

Embed
Preview of the card
<a href="https://gaiadesk.net/docs/flutter-in-app-support"><img src="https://gaiadesk.net/docs/_api/public/orgs/89a5df38-be2c-4963-8823-21d4bd40a2ab/spaces/57b99ea0-d45a-4986-8aa6-6b0683c9fe1d/pages/84d406bd-5d5a-4899-80a8-da83ead8f99b/social-card.svg?v=3e7ae33eec8b" alt="Add in-app support to a Flutter app" width="600" height="315"></a>

Give your Flutter app a "Get help" button: your customer taps it and agrees, and your support team sees your app's screen in the GaiaDesk console — and, if you allow it, guides it — without the customer installing anything.

The gaiadesk_embed 0.1.0 plugin works on iOS and Android, with Flutter 3.24 or later. It is a Dart API over GaiaDesk's native SDKs: the iOS SDK (the GaiaDeskEmbed pod) and the Android SDK (net.gaiadesk:embed-android). It is open source (MIT), at github.com/Gaia-Desk/gaiadesk-embed-flutter. The native SDKs carry the same signed native library as GaiaDesk's other embed SDKs; the library is a prebuilt binary that ships, unmodified, inside your app.

What your customer sees

  • One button. Your app shows "Get help" wherever you put it.

  • A consent dialog. It names your company, says what will be shared (this app's screen, or on Android the whole screen if you chose it) and whether your team will be able to guide it. Nothing is shared until the customer agrees.

  • An indicator for as long as anything is shared. "Sharing with Acme · Stop", drawn by the native SDK above your UI. In a guided session it also has Pause control.

  • A support code. Nine digits your customer can read to an agent over the phone.

When the session ends — the customer presses Stop, your app stops it, the session expires, or the app quits — sharing stops at once and nothing is left behind: the SDK installs nothing and writes nothing to disk.

What your support team sees

Agents open Support in the GaiaDesk console, see the waiting customer (with the details your backend passed) and join, or type the support code. Only your own account and team can join, and only team members with a support seat.

1. Add the plugin

gaiadesk_embed is not on pub.dev yet. Until it is, take it from the release tag on GitHub:

# pubspec.yaml
dependencies:
  gaiadesk_embed:
    git:
      url: https://github.com/Gaia-Desk/gaiadesk-embed-flutter.git
      ref: v0.1.0

Once it is published, this becomes gaiadesk_embed: ^0.1.0.

2. The native SDKs

iOS (15.0 or later). Set platform :ios, '15.0' in ios/Podfile, and, inside target 'Runner', take the GaiaDeskEmbed pod from its GitHub release:

pod 'GaiaDeskEmbed', :podspec => 'https://raw.githubusercontent.com/Gaia-Desk/gaiadesk-embed-ios/v0.1.0/GaiaDeskEmbed.podspec'

The pod carries the Swift SDK and the prebuilt GaiaDeskEmbedFFI.xcframework.

Android (minSdk = 26, set in android/app/build.gradle.kts). Download embed-android-0.1.0.aar from the Android SDK's v0.1.0 release and point the plugin at it in android/gradle.properties:

GaiaDeskEmbed_embedAndroidAar=/path/to/embed-android-0.1.0.aar

(or set GAIADESK_EMBED_ANDROID_AAR). Once the native SDKs are on CocoaPods trunk and Maven Central, drop both overrides: the plugin takes them from there. Nothing goes in your manifest unless you opt into sharing the whole screen (see what each platform supports).

3. Create the session on your backend

The plugin takes an embed token: your backend creates the session with a secret API key (scope support), decides who may get help, passes verified customer details, and hands the app only the token:

curl -s -X POST https://api.gaiadesk.net/v1/support/sessions \
  -H "Authorization: Bearer $GAIADESK_API_KEY" -H "Content-Type: application/json" \
  -d '{"mode": "view", "customer": {"name": "Ada", "plan": "pro"}}'

The response carries embed_token (gdemb_…), which your app passes as embedToken. Never ship the secret key in your app: the embed token is all it needs. Version 0.1.0 has no publishable-key option. The full request is in the support API reference.

4. Add the button

import 'package:flutter/material.dart';
import 'package:gaiadesk_embed/gaiadesk_embed.dart';

class HelpButton extends StatefulWidget {
  const HelpButton({super.key, required this.getEmbedToken});

  /// Asks your backend for a new session's embed token.
  final Future<String> Function() getEmbedToken;

  @override
  State<HelpButton> createState() => _HelpButtonState();
}

class _HelpButtonState extends State<HelpButton> {
  EmbedSession? _session;
  String? _code;

  Future<void> _getHelp() async {
    final consent = await GaiaDeskEmbed.requestConsent('Acme');
    if (consent == null) return; // the customer said no
    try {
      final help = await GaiaDeskEmbed.start(
        EmbedOptions(embedToken: await widget.getEmbedToken(), company: 'Acme'),
        consent: consent,
      );
      help.events.listen((e) {
        if (e is EmbedCode && mounted) setState(() => _code = e.code); // read it to the agent
      });
      if (mounted) setState(() => _session = help);
      await help.ended;
      if (mounted) setState(() {
        _session = null;
        _code = null;
      });
    } on EmbedException catch (e) {
      debugPrint('could not start: ${e.code} ${e.message}'); // bad_token, consent_required, busy, …
    }
  }

  @override
  Widget build(BuildContext context) {
    final session = _session;
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        session == null
            ? ElevatedButton(onPressed: _getHelp, child: const Text('Get help'))
            : ElevatedButton(onPressed: session.stop, child: const Text('Stop sharing')),
        if (_code != null) Text('Your support code is $_code'),
      ],
    );
  }
}

requestConsent shows the native SDK's dialog (a UIAlertController on iOS, an AlertDialog on Android) and returns an EmbedConsent, or null when the customer declines. start takes that consent: it is single-use, expires after 10 minutes, and must match the session — the same company and capture, and guided only if the customer was asked about guiding. Anything else is refused (consent_required). With your own dialog, call GaiaDeskEmbed.recordConsent(company, guided: …, capture: …) when the customer agrees, and say exactly that in it.

session.events is a broadcast Stream<EmbedEvent>; EmbedEvent is sealed, so you can switch over it exhaustively: EmbedState, EmbedCode (code, sessionId, mode), EmbedJoined (agent), EmbedLeft, EmbedControl (allowed), EmbedAction (action, applied, reason), EmbedErrorEvent (code, message) and EmbedEnded (reason: stopped, app_stopped, disconnected, expired or error) — always last, exactly once. Events before your first listener are kept for it. One session runs at a time (busy).

EmbedOptions

embedToken

gdemb_…, from your backend

company

Shown on the consent dialog and the indicator

server

Default https://gaiadesk.net

guided

Allow guided input (default false)

fps

1 to 30 (default 15)

masks

List<Rect> in logical pixels, masked from the first frame

capture

Android: EmbedCapture.app (default) or EmbedCapture.screen

captureMethod

iOS: IosCaptureMethod.replayKit (default) or IosCaptureMethod.snapshot

The consent dialog and the indicator show the company you pass. Version 0.1.0 has no colour or logo options.

Guided sessions

By default your team can only look. To let them act, create the session as cobrowse ("mode": "cobrowse") and ask for and pass guided: true — both ends must want it:

final consent = await GaiaDeskEmbed.requestConsent('Acme', guided: true);
// …
EmbedOptions(embedToken: token, company: 'Acme', guided: true)

Even then a request is applied only inside your app, while it is in front, not on a mask and not on the indicator. Your customer can pause it from the indicator, and only they can lift that pause; your app can pause too (session.setPaused(true)). Every request is reported as an EmbedAction.

  • Android: full. Clicks become taps, scrolling a mouse-wheel scroll, and typing key events, all dispatched into your activity's own window, so into the Flutter view, which handles them like any touch or key.

  • iOS: hints, not taps. iOS has no public way to synthesise a touch, and Flutter draws its own widgets with no UIKit control behind them, so in a Flutter app a guided click never presses anything: your customer sees a "Tap here" ring at that spot and taps it themselves, reported as EmbedAction(applied: false, reason: 'hint_shown'). Typing goes into a focused TextField. Plan your support flow on iOS as guiding, not driving.

Keeping things private

  • Your app only. On iOS, always; on Android, unless you choose EmbedCapture.screen.

  • Masks. Wrap anything sensitive — card numbers, balances — in GaiaDeskMasked(child: …). It is painted black before a frame is encoded, from the very first frame for widgets on screen at start. While a masked widget moves, its mask widens to cover where it was, is and is heading. A widget that appears or jumps can still show for one frame, so for such content mask the area it moves in, or a larger ancestor. You can also pass rects (masks, or session.setMaskedRects()).

  • Password fields are masked for you. Every obscured text field (obscureText: true) is found and masked without a GaiaDeskMasked, and guided typing into it is refused.

  • Consent every time. The native library refuses to start without it; there is no setting that skips the consent or hides the indicator.

What each platform supports

Capture

Guided input

Consent dialog

iOS 15.0 or later

this app only

"Tap here" hints, typing into a focused field

UIAlertController, or your own

Android 8.0 or later (API 26)

your app's window; the whole screen opt-in

yes, inside your app

AlertDialog, or your own

  • iOS: the default, IosCaptureMethod.replayKit, captures exactly what the app shows, Flutter's Metal output included; iOS asks your customer to allow recording the first time. ReplayKit is not available in the iOS Simulator: use IosCaptureMethod.snapshot there (a snapshot of the app's windows, no system prompt). EmbedCapture.screen is refused on iOS (bad_config).

  • Android: the default copies your activity's window (PixelCopy): no permission, no system dialog. EmbedCapture.screen shares the whole screen through MediaProjection: Android asks the customer too, a foreground service runs while sharing, and your app must declare in android/app/src/main/AndroidManifest.xml:

    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />

    Without them, starting fails with capture_failed. Pass the same capture to requestConsent, so the dialog says the whole screen is shared.

What is and is not permitted

You may: ship the prebuilt library unmodified inside your app, with its licence in your app's notices; offer support sessions to your own customers; show your company's name on the dialog and indicator.

You may not: modify, decompile or re-sign the library separately from your app; hide or imitate the indicator; start a session without your customer's agreement.

See the plugin's README for every option, event and error code, and in-app support for the other platforms.

Updated