Using Google Analytics SDK And Firebase SDK Together
I'm having a crash on [FIRApp configure]
step in my AppDelegate's didFinishLaunchingWithOptions
method.
Crash gives me completely no information.
But I'm using Google Analytics SDK in my app as well. Maybe that's could be the reason?
So my question is - is it possible to use both Google Analytics and Firebase SDKs at the same time in one app?
Thanks.
Answer
I resolved my problem.
For GA tracking we should use this lines of code in AppDelegate's didFinishLaunchingWithOptions
method.
guard let gai = GAI.sharedInstance() else {
assert(false, "Google Analytics not configured correctly")
}
gai.tracker(withTrackingId: "YOUR_TRACKING_ID")
For Firebase tracking we should use
FirebaseApp.configure()
in the same place.
This method is the default method for the Firebase initialization in your application. It takes all the needed for init data from the GoogleService-Info.plist
file which you should download from your dashboard on the Firebase.
And it was crashing for me on the init step.
So the actual problem:
Default GoogleService-Info.plist
file don't include the TRACKING_ID
field which is required for the Firebase initialization.
Solution:
Just add the TRACKING_ID
property to your GoogleService-Info.plist
file. The value of this property should have this format: UA-XXXXXXXX-XX.
Related Questions
- → Function Undefined in Axios promise
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Click to navigate on mobile devices
- → Playing Video - Server is not correctly configured - 12939
- → How to allow api access to android or ios app only(laravel)?
- → Axios array map callback
- → Access the Camera and CameraRoll on Android using React Native?
- → Update React [Native] View on Day Change
- → Shopify iOS SDK - issue converting BuyProductVariant to BuyProduct
- → BigCommerce and shopify API
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → React Native - Differences between Android and IOS
- → What is the difference between React Native and React?