Skip to main content
Import the main package for core APIs, config, enums, and the inline in-app widget:
import 'package:zixflow/zixflow.dart';
For inbox models and in-app event types, also import:
import 'package:zixflow/messaging_in_app.dart';

Core SDK

Zixflow.initialize({required ZixflowConfig config}): Future<void>

Initialize the SDK with configuration. Call once before using other APIs.
await Zixflow.initialize(
  config: ZixflowConfig(apiKey: 'YOUR_API_KEY'),
);

Zixflow.instance

Singleton instance. Throws StateError if the SDK has not been initialized.

Zixflow.instance.identify({required String userId, Map<String, dynamic> traits}): void

Identify a user. Provide a unique userId and optional traits.
Zixflow.instance.identify(
  userId: 'user-123',
  traits: {'email': 'user@example.com'},
);

Zixflow.instance.clearIdentify(): void

Clear the current user’s identity.
Zixflow.instance.clearIdentify();

Zixflow.instance.track({required String name, Map<String, dynamic> properties}): void

Track a custom event.
Zixflow.instance.track(
  name: 'button_clicked',
  properties: {'button_name': 'signup'},
);

Zixflow.instance.screen({required String title, Map<String, dynamic> properties}): void

Track a screen view.
Zixflow.instance.screen(title: 'HomeScreen');

Zixflow.instance.setProfileAttributes({required Map<String, dynamic> attributes}): void

Set attributes on the user profile.
Zixflow.instance.setProfileAttributes(
  attributes: {'plan': 'premium'},
);

Zixflow.instance.setDeviceAttributes({required Map<String, dynamic> attributes}): void

Set attributes on the current device.
Zixflow.instance.setDeviceAttributes(
  attributes: {'app_version': '2.0.0'},
);

Zixflow.instance.registerDeviceToken({required String deviceToken}): void

Register a device token for push notifications.
Zixflow.instance.registerDeviceToken(deviceToken: token);

Zixflow.instance.deleteDeviceToken(): void

Remove the current device token.
Zixflow.instance.deleteDeviceToken();

Zixflow.instance.trackMetric({required String deliveryID, required String deviceToken, required MetricEvent event}): void

Track push delivery metrics manually.
Zixflow.instance.trackMetric(
  deliveryID: '626533406292836846',
  deviceToken: token,
  event: MetricEvent.delivered, // or MetricEvent.opened / MetricEvent.converted
);

Push Messaging

Zixflow.pushMessaging.getRegisteredDeviceToken(): Future<String?>

final token = await Zixflow.pushMessaging.getRegisteredDeviceToken();

Zixflow.pushMessaging.onMessageReceived(Map<String, dynamic> message, {bool handleNotificationTrigger = true}): Future<bool>

Process an FCM data message on Android (displays and/or tracks). On iOS this resolves to true without additional work.
await Zixflow.pushMessaging.onMessageReceived(message);

Zixflow.pushMessaging.onBackgroundMessageReceived(Map<String, dynamic> message): Future<bool>

Background helper around onMessageReceived (Android).
await Zixflow.pushMessaging.onBackgroundMessageReceived(message);

In-App Messaging

Zixflow.inAppMessaging.subscribeToEventsListener(void Function(InAppEvent) onEvent): StreamSubscription

final subscription =
    Zixflow.inAppMessaging.subscribeToEventsListener((event) {
  print('In-app event: ${event.eventType}');
});
subscription.cancel();

Zixflow.inAppMessaging.dismissMessage(): void

Zixflow.inAppMessaging.dismissMessage();

Zixflow.inAppMessaging.inbox: NotificationInbox

Returns the notification inbox helper. See In-App Messaging for usage.
MethodDescription
getMessages({String? topic})Fetch inbox messages
messages({String? topic})Stream of inbox message changes
markMessageOpened(message)Mark as read
markMessageUnopened(message)Mark as unread
markMessageDeleted(message)Delete message
trackMessageClicked(message, {String? actionName})Track a click

InlineInAppMessageView

Flutter widget for inline in-app placements. Requires elementId. Available on Android and iOS.
InlineInAppMessageView(
  elementId: 'my-message',
  onActionClick: (message, actionValue, actionName) {
    print('$actionName $actionValue');
  },
)

Location

Zixflow.location.setLastKnownLocation({required double latitude, required double longitude}): void

Zixflow.location.setLastKnownLocation(
  latitude: 37.7749,
  longitude: -122.4194,
);

Zixflow.location.requestLocationUpdate(): void

Zixflow.location.requestLocationUpdate();

Types

ZixflowConfig

ZixflowConfig({
  required String apiKey,
  LogLevel? logLevel,
  bool? autoTrackDeviceAttributes,
  bool? trackApplicationLifecycleEvents,
  ScreenView? screenViewUse,
  String? apiHost,
  String? cdnHost,
  int? flushAt,
  int? flushInterval,
  InAppConfig? inAppConfig,
  PushConfig? pushConfig,
  LocationConfig? locationConfig,
});

LogLevel

enum LogLevel { none, error, info, debug }

ScreenView

enum ScreenView { all, inApp }

LocationTrackingMode

enum LocationTrackingMode { off, manual, onAppStart }

MetricEvent

enum MetricEvent { delivered, opened, converted }

PushClickBehaviorAndroid

enum PushClickBehaviorAndroid {
  resetTaskStack,
  activityPreventRestart,
  activityNoFlags,
}

PushConfig / PushConfigAndroid

PushConfig(
  android: PushConfigAndroid(
    pushClickBehavior: PushClickBehaviorAndroid.activityPreventRestart,
  ),
)

LocationConfig

LocationConfig(
  trackingMode: LocationTrackingMode.manual,
)

EventType

enum EventType {
  messageShown,
  messageDismissed,
  errorWithMessage,
  messageActionTaken,
}

InAppEvent

class InAppEvent {
  final EventType eventType;
  final InAppMessage message;
  final String? actionValue;
  final String? actionName;
}