Moments API module
Learn how to install the Tealium Moments API module for Flutter.
Tealium for Flutter lets you use the Tealium mobile libraries (iOS, Android) to install the Moments API Module for the Tealium Flutter plugin.
How it works
Tealium mobile libraries can be integrated into your Flutter application using one of the following methods:
- Dart package (Recommended)
- Manually with GitHub
Requirements
- Flutter application development framework
- IDE, such as Android Studio or VS Code
- Flutter plugin installed on the IDE
Install
To install the Tealium library for Flutter:
- In your Flutter app project, run the following command:
dart pub add tealium_moments_api - Import the following Dart code into your project:
import 'package:tealium_moments_api/common.dart'; import 'package:tealium_moments_api/tealium_moments_api.dart';
Initialize
Configure the Moments API module before initializing the main Tealium Flutter integration.
Set the Moments API Region as specified in the Moments API interface. The following regions are available:
GERMANYUS_EASTSYDNEYOREGONTOKYOHONG_KONG
If you are using the domain allow list, set the referrer to an allowed domain.
The following example code uses the US_EAST region and example.com as the referrer to match the allowed domain:
MomentsApiConfig config = MomentsApiConfig(
MomentsApiRegion.US_EAST, // required
"https://example.com"); // optional
// Configure the module
TealiumMomentsApi.configure(config);
// ... Initialize main Tealium plugin
Class: TealiumMomentsApi
After the Moments API Module and the main Tealium Flutter integration have both been initialized, you can retrieve engine data by ID.
fetchEngineResponse
Retrieves the engine response for the given engine ID.
TealiumMomentsApi.fetchEngineResponse(
engineId: "ENGINEID",
callback: (response) {
if (response is EngineResponse) {
// handle success
final audiences = response.audiences;
// do something
} else if (response is String) {
// handle error
}
}
);
Parameters
| Parameter | Type | Description |
|---|---|---|
engineId |
String |
The ID of the engine to check |
callback |
Function(dynamic) |
Callback that receives an EngineResponse on success or a String error message on failure |
EngineResponse
The EngineResponse class contains the visitor data returned from the Moments API engine.
| Property | Type | Description |
|---|---|---|
audiences |
List<String>? |
Audience IDs the visitor belongs to |
badges |
List<String>? |
Badges assigned to the visitor |
strings |
Map<String, String>? |
String attributes |
booleans |
Map<String, bool>? |
Boolean attributes |
dates |
Map<String, int>? |
Date attributes (as timestamps) |
numbers |
Map<String, double>? |
Numeric attributes |
This page was last updated: March 31, 2026