Flutter setup

Install invitebase_flutter, wire deep links, and understand the platform-channel architecture

invitebase_flutter is a Flutter plugin over the native iOS and Android SDKs via platform channels. Attribution runs natively — clipboard handoff on iOS, Play Install Referrer on Android — so a Flutter app gets the same attribution quality as a fully native one. Observers arrive as Dart Streams, so widgets rebuild on referral changes with a plain StreamBuilder.

This page covers installation and platform wiring. The methods themselves are documented once for all platforms in the SDK reference. For a guided first integration, see the Flutter quickstart.

Install

pubspec.yaml
dependencies:
  invitebase_flutter: ^1.0.0
flutter pub get

The plugin uses federated platform interfaces; iOS 15+ and Android API 24+ are supported.

Configure before runApp

Call configure once before runApp. It generates (or restores) the anonymous ID (Keychain on iOS, EncryptedSharedPreferences on Android) and starts deferred attribution on first launch.

main.dart
import 'package:flutter/widgets.dart';
import 'package:invitebase_flutter/invitebase_flutter.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Invitebase.configure(publishableKey: 'pk_test_51Hq2jK');
  runApp(const MycompanyApp());
}

Deferred attribution needs no setup. For the already-installed path (Universal Links / App Links), register your Apple Team ID + bundle ID and Android package name + signing fingerprints in the dashboard under Settings → Attribution — Invitebase serves the AASA and assetlinks.json files for your {app}.refr.link subdomain. Then:

  • iOS: add the Associated Domains capability with applinks:mycompany.refr.link in Xcode (details).
  • Android: add the autoVerify intent filter for mycompany.refr.link to AndroidManifest.xml (details).

Forward incoming URIs to handleInbound with any deep-link package — non-referral URIs are ignored:

import 'package:app_links/app_links.dart';

final appLinks = AppLinks();

// Cold start
final initial = await appLinks.getInitialLink();
if (initial != null) Invitebase.handleInbound(initial);

// While running
appLinks.uriLinkStream.listen((uri) {
  Invitebase.handleInbound(uri);
});

Push notifications

If you use Invitebase-managed referral push notifications — the default delivery mode — forward the native device token — the APNs token on iOS, the FCM registration token on Android:

import 'dart:io';
import 'package:firebase_messaging/firebase_messaging.dart';

final token = Platform.isIOS
    ? await FirebaseMessaging.instance.getAPNSToken()
    : await FirebaseMessaging.instance.getToken();
if (token != null) await Invitebase.setPushToken(token);

// Android rotates FCM tokens — keep the stored token current
FirebaseMessaging.instance.onTokenRefresh.listen(Invitebase.setPushToken);

The SDK attaches the token to the current user — anonymous or identified. Details in setPushToken.

Bringing your own push provider instead? Skip this — device tokens stay on your side, and Invitebase will hand each notification to your backend as a notification.due webhook (bring-your-own-push is planned, not yet available).

Platform-channel notes

  • The plugin is a thin Dart layer; identity storage, event batching, attribution, and observer refresh all run in the native SDKs. Behavior in a Flutter app is byte-for-byte the behavior documented on the iOS and Android setup pages.
  • Channel calls are asynchronous; the UI isolate is never blocked.
  • On iOS, the clipboard paste affordance is a native view (UIPasteControl requires a real system control). The plugin exposes it as an InvitebasePasteButton widget backed by a platform view.
  • Add-to-app setups work: configure the native SDKs yourself and the Dart layer attaches to the existing instance.

On this page