Moments API Module
Learn how to install the Tealium Moments API module for React Native.
How it works
Tealium mobile libraries are integrated into your React Native application using one of the following methods:
- NPM package (recommended)
- Manual via GitHub
After you install the Moments API module, import the necessary classes into your app and initialize the Moments API module.
Requirements
The Tealium Moments API module requires the following:
- Access to your native build environments
- Tealium for React Native 2.2.0 or later
- React Native 0.63 or later and tools
- Tealium iQ Mobile Profile
- Android Studio or Xcode
- Tealium for Android or Tealium for iOS
Install (NPM/YARN)
To install the Tealium Moments API module for React Native with NPM:
- Follow the installation instructions for the main
tealium-react-native
library installation. Ensure that you have installed at least version 2.2.0 or later. - Go to the root directory of your React Native project.
- Download and install the
tealium-react-native-moments-api
package with the following command:yarn install tealium-react-native-moments-api
JavaScript
To import the relevant classes into your app, add the following code:
import TealiumMomentsApi from 'tealium-react-native-moments-api';
import { TealiumMomentsApiConfig, MomentsApiRegion} from 'tealium-react-native-moments-api/common';
Initialize
Configure the Moments API
module prior to initializing the main Tealium React Native integration. Use TealiumMomentsApiConfig
parameters to enable settings as needed.
let momentsApiConfig: TealiumMomentsApiConfig = {
region: MomentsApiRegion.UsEast, // Setting a region is mandatory. The Moments API module will not initialize if it is missing.
referrer: "https://tealium.com" // Optional - specify a referrer URL. This URL must match the “Domain Allow List” in the Tealium UI, or the Moments API will not return any data.
}
TealiumMomentsApi.configure(momentsApiConfig);
API Reference
After the Moments API Module and the main Tealium React Native integration have both been initialized, you can retrieve engine data by ID.
fetchEngineResponse(engineId, callback)
Retrieves the engine response for the given engine ID.
TealiumMomentsApi.fetchEngineResponse(
id,
value => {
console.log("Engine Response data: " + JSON.stringify(value))
}
);
This page was last updated: September 5, 2024