You will be working with the Tealium native mobile libraries, so any existing documentation on those topics is relevant, and at times you may be directed to them from this guide. You can find more information on them in our Tealium for Android and Tealium for iOS guides.
The Core library is required. If you want to track lifecycle events, then the lifecycle module is also needed. These are available from our GitHub repository for iOS. There are two versions of each module: one for publishing to the App Store and one that includes the ability to run the app on a simulator (cannot be published to the App Store). When working on your own app with intent to publish to the App Store, make sure to use the frameworks in devices only folder.
Install via NPM
In the root of your React Native project, run the following:
npm install tealium-react-native
The first command will download the tealium-react-native package and install it to your project.
The second command will link the native dependencies within the module to your main React Native app so that it can build against the module.
At this point your Android app should build and work without issues. We recommend building using the IDE since we’ve found that to be more reliable. However, apps can also be started from the Command Line Interface (CLI).
First, obtain a copy of Tealium for iOS. The two libraries you need are TealiumIOS.framework and TealiumIOSLifecycle.framework. Drag the frameworks into the Libraries folder in your Xcode project, and from there drag them into the Embedded Binaries section under the General tab of your target.
Finally, under Libraries find TealiumModule.xcodeproj. Within, you will find a Products folder containing a libTealiumModule.a file.
If you’re looking for Libraries > TealiumModule.xcodeproj > Products > libTealiumModule.a. Under the Build Phases tab of your target, you will find a Link Binary With Libraries section. Drag the libTealiumModule.a file to the Link Binary With Libraries section. More information on linking libraries can be found in the React Native documentation.
To integrate Tealium into your Android application, add this to your Tealium maven repository:
In your project root build.gradle, add the Tealium Maven URL:
Adding Tealium for iOS to a React Native project requires the same steps for a non-React Native application (with the exception of the bridging files), so reference Adding Tealium to Your iOS App for complete details.
The sample app is for developer experimentation and not meant for publishing on the App Store, so it uses the modules TealiumIOS.framework and TealiumIOSLifecycle.framework (suitable for a simulator but not for publishing). When working on your own app with intent to publish to the App Store, make sure to use the frameworks in the devices only folder.
Installation can also be done with CocoaPods. Our pod is named “TealiumIOS”. See the Tealium for iOS guide for full details. The command create-react-native-app does not create a Podfile so the sample app was built using manual installation. For complex production apps with many dependencies, CocoaPods is the recommended method.
Copy Bridging Logic
Copy these two files into your app’s main project. It should “just work” assuming your project has correctly included any React Native dependencies and the Tealium iOS library.
The method for importing the module into your app will depends on how you installed above.
If you installed via NPM, add this line to your code:
import Tealium from 'tealium-react-native';
import Tealium from './TealiumModule';
Once your app has been built you are ready to start coding. The Tealium instance must be invoked with the following parameters before you can begin tracking:
account – the name of your account
profile – the name of your profile
environment – (optional) one of “dev”, “qa”, or “prod”
iOS data source – (optional) the data source key from UDH
Android data source – (optional) the data source key from UDH