lemnisk_flutter 1.2.0
lemnisk_flutter: ^1.2.0 copied to clipboard
The Lemnisk Flutter Plugin allows you to track user event data from your Android or IOS app. The Plugin can be easily imported into any Android or iOS app. Based on the data it receives from the user [...]
lemnisk_flutter #
The Lemnisk Flutter plugin is a thin wrapper over the Lemnisk Android and iOS native SDKs. It lets you track user event data from your Flutter app and deliver real-time personalized push notifications and in-app campaigns.
Installation #
Add the plugin to your pubspec.yaml and run flutter pub get.
The plugin depends on the native SDKs:
- Android:
co.lemnisk.app.android:AndroidSDK:1.2.0 - iOS:
Lemnisk-iOS-SDK3.10.0
Usage #
Import the plugin:
import 'package:lemnisk_flutter/flutter_wrapper_method_channel.dart';
Event tracking #
await LemniskFlutter.track('product_viewed', {'sku': 'ABC123'});
await LemniskFlutter.screen('Product Page', {'category': 'shoes'});
await LemniskFlutter.identify('user123', {'email': 'a@b.com'});
Push notifications #
final result = await LemniskFlutter.registerForPushNotifications(null, null);
// Observe notification taps
LemniskFlutter.onNotificationTapped.listen((data) {
// handle the deeplink / payload
});
In-app campaigns #
In-app popups render natively — there is nothing to render on the Flutter side. Two sets of controls let you tune when they appear.
Context — drives in-app campaign context conditions. Set it to a stable identifier for the part of the app the user is in (for example the active tab or section), and clear it when it no longer applies:
await LemniskFlutter.setContext('wishlist');
// ...
await LemniskFlutter.clearContext();
Pause / resume — suppress in-app popups on screens where they would be disruptive (checkout, video playback, etc.), then re-enable them:
await LemniskFlutter.pauseInApp();
// ...
await LemniskFlutter.resumeInApp();
Readiness check #
final ready = await LemniskFlutter.isInitialized();
With auto-init this is normally already true by the time Dart runs, since the
native SDK configures itself at launch (see below). Useful as a defensive guard.
Configuration & auto-initialization #
Lemnisk configures itself from native config files — AndroidManifest.xml
on Android and Info.plist on iOS. There is no Dart configure() call: the
native SDKs initialize automatically at app launch (Android via a
ContentProvider that runs before Application.onCreate; iOS via a launch
observer during didFinishLaunching). Both fire before the Flutter engine is
up, which is why the config must live in the native files — this is the same
model Firebase uses (google-services.json / GoogleService-Info.plist).
You configure the same logical key set once per platform. The key names differ
by platform (Android uses dotted Lemnisk.* meta-data; iOS uses flat
Lemnisk* keys).
Android — android/app/src/main/AndroidManifest.xml #
Add inside <application>:
<meta-data android:name="Lemnisk.WRITE_KEY" android:value="YOUR_WRITE_KEY" />
<meta-data android:name="Lemnisk.SERVER_URL" android:value="https://tpl.lemnisk.co" />
<meta-data android:name="Lemnisk.ENABLE_PUSH" android:value="true" />
<meta-data android:name="Lemnisk.ENABLE_INAPP" android:value="true" />
<meta-data android:name="Lemnisk.DEBUG_MODE" android:value="true" />
<!-- optional: Lemnisk.Consent_URL, Lemnisk.ENABLE_ANALYTICS,
Lemnisk.ENABLE_PULL_NOTIFICATIONS, Lemnisk.ENABLE_GEOFENCE, Lemnisk.ENABLE_BP,
Lemnisk.ADSERVER_URL, Lemnisk.NOTIFICATION_CENTER_URL, Lemnisk.NOTIFICATION_ICON,
App.DeepLinkPrefix -->
Auto-init arms only when Lemnisk.WRITE_KEY is present. To keep the keys but
opt out of auto-init, set <meta-data android:name="Lemnisk.AUTO_INIT" android:value="false" /> (absent or true → auto-init runs — same semantics as
iOS LemniskAutoInit).
iOS — ios/Runner/Info.plist #
<key>LemniskWriteKey</key> <string>YOUR_WRITE_KEY</string>
<key>LemniskServerUrl</key> <string>https://tpl.lemnisk.co</string>
<key>LemniskPushEnabled</key> <true/>
<key>LemniskInAppEnabled</key> <true/>
<key>LemniskAnalyticsEnabled</key> <true/>
<!-- optional: LemniskAppGroupId, LemniskNotificationCenterUrl,
LemniskConsentServerUrl -->
Auto-init arms when both LemniskWriteKey and LemniskServerUrl are present.
Set <key>LemniskAutoInit</key><false/> to opt out without removing the keys.
Logical key mapping #
| Purpose | Android meta-data | iOS Info.plist |
|---|---|---|
| Write key (arms init) | Lemnisk.WRITE_KEY |
LemniskWriteKey |
| Server URL | Lemnisk.SERVER_URL |
LemniskServerUrl |
| Push enabled | Lemnisk.ENABLE_PUSH |
LemniskPushEnabled |
| In-app enabled | Lemnisk.ENABLE_INAPP |
LemniskInAppEnabled |
| Analytics enabled | Lemnisk.ENABLE_ANALYTICS |
LemniskAnalyticsEnabled |
| App group id | (n/a) | LemniskAppGroupId |
| Notification-center URL | Lemnisk.NOTIFICATION_CENTER_URL |
LemniskNotificationCenterUrl |
| Consent URL | Lemnisk.Consent_URL |
LemniskConsentServerUrl |
| Auto-init opt-out | Lemnisk.AUTO_INIT = false |
LemniskAutoInit = false |
iOS push-delegate note #
Config (write key, server URL, app group, feature flags) belongs in
Info.plist. Any push-handling customization — owning the
UNUserNotificationCenter delegate, forwarding notification taps to Flutter,
setSwizzleForNotificationCenterDelegates(...) — still lives in your
AppDelegate.swift. Do this in didFinishLaunchingWithOptions (it runs before
auto-init).
You do not need an explicit Lemnisk.shared.configure(...) call anymore. If
you keep one for backward compatibility it must run inside
didFinishLaunchingWithOptions (before auto-init), in which case auto-init
detects it and stands down — so the SDK still initializes exactly once.