Skip to content
Notifie
Documentation
DocsSDKs

SDKs

Flutter SDK

A thin bridge over the native Swift and Android implementations, with Dart callbacks for receipt and open.

Install

Terminal
flutter pub add notifie_flutter:^0.1.0-beta.10

The package delegates to the native SDKs rather than reimplementing them, so iOS registers APNs tokens directly and Android goes through FCM. You do not add a second APNs key to Firebase.

Initialize before runApp

main.dart
WidgetsFlutterBinding.ensureInitialized();

await Notifie.initialize(
  apiKey: env.notifieKey,
  batchSize: 20,
  maxQueueSize: 1000,
  flushInterval: const Duration(seconds: 30),
  requestTimeout: const Duration(seconds: 15),
  onNotificationReceived: (n) => debugPrint('received ${n.title}'),
  onNotificationOpened: (n) => router.open(n.deepLink),
  onError: (e) => reportToCrashlytics(e),
);

runApp(const App());
ParameterDefaultMeaning
apiKeyrequiredSDK ingest key
baseUrlhttps://notifie.devAdvanced override for local integration tests
anonymousIdgeneratedSupply one to reuse an existing device identity
batchSize20Events per upload
maxQueueSize1000Offline cap
flushInterval30sAutomatic flush cadence
requestTimeout15sPer-request timeout
registerFirebaseBackgroundHandlertrueSet false if your app owns the FCM background handler

Production apps omit baseUrl; the hosted Notifie API is the default.

Identity and events

order_service.dart
await Notifie.identify('user-42', properties: {'plan': 'pro'});

await Notifie.track(
  'order_shipped',
  properties: {'order_id': order.id},
);

await Notifie.flush();
await Notifie.reset();   // on logout

reset clears the identity and queued events, then restores a fresh device token so the next user still receives push.

Push notifications

Enrol when the value is obvious
await Notifie.enableNotifications();

This performs the platform-appropriate flow: POST_NOTIFICATIONS plus an FCM token on Android, and the system prompt plus a direct APNs registration on iOS. Use Notifie.registerPushToken(...) only if your app already owns token retrieval.

On Android, adding google-services.json is necessary but not sufficient. Nothing reads that file until the Google Services Gradle plugin turns it into the resources Firebase looks up at runtime, so a project with the file and without the plugin fails exactly like a project with neither. Add both:

android/settings.gradle.kts
plugins {
    // ...existing plugins
    id("com.google.gms.google-services") version "4.4.2" apply false
}
android/app/build.gradle.kts
plugins {
    // ...existing plugins
    id("com.google.gms.google-services")
}

Then place google-services.json at android/app/google-services.json. On iOS, add GoogleService-Info.plist to the Runner target in Xcode so it is copied into the bundle — adding it to the folder alone does not add it to the target. notifie doctor checks both.