在iOS应用程序和Firebase/Google Analytics(分析)中配置多个Firebase项目运行时 [英] Configure Multiple Firebase Projects Runtime in iOS application and Firebase/Google Analytics

查看:313
本文介绍了在iOS应用程序和Firebase/Google Analytics(分析)中配置多个Firebase项目运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将开始从Google Analytics(分析)迁移到Firebase Analytics(分析),因为它将在一年内弃用.我们需要在iOS应用程序中初始化firebase项目运行时,并且正在执行此处提到的步骤: https://firebase.google.com/docs/projects/multiprojects?authuser=0

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

为什么我们需要在运行时手动初始化firebase?有关详细信息,请参见本期:在不同对象之间切换一个单个APK文件中的Firebase项目(运行时)

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

当我们在Android上遇到类似的推送通知问题时,我发布了该问题,因为当时文档还不够.很高兴知道Firebase文档已更新,以反映如何针对各种平台手动初始化sdk.

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.

问题:我们今天面临的问题是,一旦我们手动初始化了SDK(例如次要"应用程序)并尝试使用Firebase分析,该SDK就会失败,并出现以下错误:

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

下面是示例代码:

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];
}

看着错误,它告诉我们使用[FIRApp configure],它从项目中的GoogleService-Info.plist配置默认应用程序.但是我们不要按照 https://firebase.google.com/docs/projects/multiprojects?authuser=0 .

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::我们正在使用API​​ [FIRApp configureWithName:@"testApp" options:firoptions]在iOS应用中手动初始化firebase应用.并且Firebase Analytics出现错误,要求我们使用默认的[FIRApp configure],这违背了手动初始化的目的.

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.

推荐答案

Firebase Analytics要求将文件命名为GoogleService-Info.plist.请注意 https://firebase.google.com/docs/projects的第一段/multiprojects?authuser = 0 建议通过将其放在不同目录中来区分多个版本.

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.

有关FirebaseAnalytics和多个plist文件的更多详细信息,请参见 https://github. com/firebase/firebase-ios-sdk/issues/230

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

这篇关于在iOS应用程序和Firebase/Google Analytics(分析)中配置多个Firebase项目运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆