Integrate with Firebase
This page covers every SDK platform and version. A part that applies only to some platforms starts with Platform: …, and a part that applies only to some SDK versions starts with SDK version: ….
If you're using the Firebase SDK alongside the justtrack SDK, you can use the justtrack SDK to send a user's Firebase App Instance ID to the justtrack backend. Later, the justtrack backend can forward events to Firebase, allowing you to measure events happening outside your app. To enable this, the justtrack backend needs the user's Firebase App Instance ID.
We provide two approaches for integrating Firebase SDK with justtrack SDK.
Platform: AndroidBefore you begin
Please review the following compatibility matrix to make sure you're using compatible versions:
| justtrack SDK | Firebase Adapter | Firebase BOM |
|---|---|---|
| 6.0.0+ | 1.x | 29.x. |
Option 1: Provide Firebase App Instance ID directly
// During SDK initialization
val sdk = new JustTrackSdkBuilder(this, API_TOKEN)
.setFirebaseAppInstanceId("... provide user's Firebase app instance ID here")
.build()
// Or after...
sdk.setFirebaseAppInstanceId("... provide user's Firebase app instance ID here")
Option 2: Integrate with Firebase
First, add the adapter dependency to your package manager:
- Kotlin
- Groovy
dependencies {
implementation("io.justtrack:adapter-firebase:1.0.0")
}
dependencies {
implementation "io.justtrack:adapter-firebase:1.0.0"
}
Then, initialize the adapter, and integrate it with the justtrack SDK:
import io.justtrack.integrations.firebase.FirebaseIntegrationAdapter
// Integrate the adapter while you build the SDK
val sdk = JustTrackSdkBuilder(this, API_TOKEN)
.addIntegrationAdapters(FirebaseIntegrationAdapter())
.build()
// Or after...
sdk.integrateWith(FirebaseIntegrationAdapter())
Before you begin
Please review the following compatibility matrix to make sure you're using compatible versions:
| justtrack SDK | Firebase Adapter | Firebase SDK |
|---|---|---|
| 6.0.0+ | 1.x | 11.x - 12.x |
Option 1: Provide Firebase App Instance ID directly
// During SDK initialization
let sdk = try JustTrackSdkBuilder(apiToken: apiToken)
.set(trackingId: trackingId, trackingProvider: trackingProvider)
.set(firebaseAppInstanceId: "... provide user's Firebase app instance ID here")
.build()
// Or after...
sdk.set(firebaseAppInstanceId: "... provide user's Firebase app instance ID here")
Option 2: Integrate with Firebase
First, add the adapter dependency to your package manager:
- Cocoa Pods
- Swift Package Manager
- Carthage
pod 'JustTrackSDKFirebaseAdapter', '~> 1.0.0'
https://github.com/justtrackio/justtrack-sdk-spm.git
binary "https://sdk.justtrack.io/carthage/JustTrackSDKFirebaseAdapter.json"
Then, initialize the adapter, and integrate it with the justtrack SDK:
import JustTrackSDK
import JustTrackSDKFirebaseAdapter
// Create SDK first
let sdk = try JustTrackSdkBuilder(apiToken: apiToken)
.set(trackingId: trackingId, trackingProvider: trackingProvider)
.build()
// Then integrate the Firebase adapter
sdk.integrate(with: JusttrackFirebaseAdapter())
Before you begin
Please review the following compatibility matrix to make sure you're using compatible versions:
| justtrack SDK | Firebase Adapter | Firebase BOM |
|---|---|---|
| 6.0.0+ | 1.x | 22.x |
Option 1: Provide Firebase App Instance ID directly
// Set the Firebase App Instance ID after initializing the justtrack SDK
sdk.setFirebaseAppInstanceId("... provide user's Firebase app instance ID here");
Option 2: Integrate Firebase adapter
First, add the adapter dependency to your package manager:
npm install justtrack-adapter-firebase --save
Then, initialize the adapter, and integrate it with the justtrack SDK:
import { registerAdapter as registerFirebaseAdapter } from 'justtrack-adapter-firebase';
// Register the adapter after initializing the justtrack SDK
registerFirebaseAdapter();
If you're using the Firebase SDK alongside the justtrack SDK, you can use the justtrack SDK to send a user's Firebase App Instance ID to the justtrack backend. Later, the justtrack backend can forward events to Firebase, allowing you to measure events happening outside your app. To enable this, the justtrack backend needs the Firebase App Instance ID of the user.
Before you begin
Review the following compatibility matrix to make sure you're using compatible versions. Automatic uses the default version.
| Platform | Firebase Adapter | Firebase SDK |
|---|---|---|
| Android | 1.x (default) | 12.x - 13.x |
| iOS | 1.x (default) | 12.x - 13.x |
Integrate with Firebase
- In the Unity Editor, navigate to the justtrack SDK configuration prefab.
- Select the Android or iOS tab, and enable Add Firebase Adapter. This automatically publishes the Firebase App Instance ID to the justtrack backend for that platform.
- Optional: In Adapter Version, choose the adapter version that matches your Firebase SDK. See Choose an adapter version.
- Call the integration method in your code:
using JustTrack;
// Call this after SDK initialization
JustTrackSDK.IntegrateWithFirebase(
pOnSuccess: () => {
Debug.Log("Firebase integration successful");
},
pOnFailure: (error) => {
Debug.LogError($"Firebase integration failed: {error}");
}
);
Choose an adapter version
You can choose which adapter version the justtrack SDK adds to your project. After you enable an adapter, an Adapter Version menu appears below it with these options:
- Automatic: Uses the default adapter version for your installed justtrack SDK. Use this option unless your third-party SDK version needs a different adapter.
- A specific version, such as 1.0.0 or 2.0.0: Uses the latest stable release of that major version. Choose the version that matches your third-party SDK in the compatibility matrix.
- Custom: Lets you enter any version. Enter an adapter version that's already published. If the version doesn't exist, the justtrack SDK uses the default version instead.
Firebase integration currently is not available for justtrack Flutter SDK.