SDKs
Flutter SDK
A thin bridge over the native Swift and Android implementations, with Dart callbacks for receipt and open.Install
flutter pub add notifie_flutter:^0.1.0-beta.10The 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
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());| Parameter | Default | Meaning |
|---|---|---|
apiKey | required | SDK ingest key |
baseUrl | https://notifie.dev | Advanced override for local integration tests |
anonymousId | generated | Supply one to reuse an existing device identity |
batchSize | 20 | Events per upload |
maxQueueSize | 1000 | Offline cap |
flushInterval | 30s | Automatic flush cadence |
requestTimeout | 15s | Per-request timeout |
registerFirebaseBackgroundHandler | true | Set false if your app owns the FCM background handler |
Production apps omit baseUrl; the hosted Notifie API is the default.
Identity and events
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 logoutreset clears the identity and queued events, then restores a fresh device token so the next user still receives push.
Push notifications
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:
plugins {
// ...existing plugins
id("com.google.gms.google-services") version "4.4.2" apply false
}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.