Configure Multiple Firebase Projects Runtime in iOS application and Firebase/Google Analytics

不想你离开。 提交于 2019-12-11 01:08:19

问题


We are starting to migrate from Google Analytics to Firebase Analytics as it is going to be deprecated in a year. We have a need of initializing the firebase project runtime in our iOS application and we are following the steps mentioned here: https://firebase.google.com/docs/projects/multiprojects?authuser=0

Why do we need to initialize the firebase manually and at runtime? The details are in this issue: Switching between different firebase projects (runtime) in one single APK file

I posted that issue when we encountered a similar problem for push notifications on Android because at that time the documentation was not sufficient. It is really good to know that firebase documentation has been updated to reflect how to manually initialize the sdk for various platforms.

Problem: The problem that we are facing today is that once we initialize the SDK manually for say a "secondary" application and we try to use the firebase analytics, it fails with following error:

2018-12-20 17:14:33.526757-0800 App Name[9218:675367] 5.2.0 - [Firebase/Analytics][I-ACS025018] Event not logged. Call +[FIRApp configure]: AppLaunch

Below is the sample piece of code:

FIROptions *firoptions = [[FIROptions alloc] initWithGoogleAppID:@"Actual_GoogleAppId" GCMSenderID:@"Actual_GCMSenderId"];
firoptions.bundleID = @"actual.bundle.id";
firoptions.APIKey = @"actual-api-key";
firoptions.clientID = @"actual.client.id";
firoptions.databaseURL = @"https://actual.url";
firoptions.storageBucket = @"actualapp.appspot.com";

[FIRApp configureWithName:@"testApp" options:firoptions];

if ([FIRApp appNamed:@"testApp"]) {
    [FIRAnalytics logEventWithName:@"AppLaunch" parameters:nil];
}

Looking at the error it tells us to use [FIRApp configure] which configures the default application from the GoogleService-Info.plist in the project. But we do not have GoogleService-Info.plist in our project as suggested in https://firebase.google.com/docs/projects/multiprojects?authuser=0.

TL;DR: We are initializing the firebase app manually in our iOS application using the API [FIRApp configureWithName:@"testApp" options:firoptions]; and the Firebase Analytics gives an error asking us to use default [FIRApp configure] which defeats the purpose of manual initialization.

Any help is greatly appreciated.


回答1:


Firebase Analytics requires the file to be named GoogleService-Info.plist. Note the first paragraph of https://firebase.google.com/docs/projects/multiprojects?authuser=0 recommends differentiating multiple versions of it by putting them in different directories.

More details about FirebaseAnalytics and multiple plist files at https://github.com/firebase/firebase-ios-sdk/issues/230



来源:https://stackoverflow.com/questions/53878190/configure-multiple-firebase-projects-runtime-in-ios-application-and-firebase-goo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!