Integrate with Firebase
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.
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())