适用于单个应用程序的Firebase Analytics(两个项目) [英] Firebase Analytics (Two projects) for single app

查看:98
本文介绍了适用于单个应用程序的Firebase Analytics(两个项目)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对一个应用程序和一个代码使用两个Firebase Analytics.

I want to use TWO Firebase Analytics for one single app, one single code.

项目1:Firebase Analytics测试项目 项目2:Firebase Analytics产品项目

Project 1: Firebase Analytics Test Project Project 2: Firebase Analytics Prod Project

如何在一个项目中添加两个google-services.json文件.还有其他使用方法吗?

How can I add two google-services.json file in one single project. Is there any other way to use the same.

推荐答案

Analytics在您的GoogleService-Info.plist中仅使用1个Google App ID.无法将流量发送到两个项目.我建议有2个单独的项目用于测试和发布版本.不建议将测试数据与生产数据混淆,因为如果其中包含测试数据,生产数据可能无法反映真实的行为.例如,如果您每天晚上通过安装和卸载来运行测试"应用程序,则可能似乎每天在您的生产应用程序中都有一个新用户.

Analytics works with only 1 Google App ID in your GoogleService-Info.plist. There is no way to send traffic to both projects. I'd recommend to have 2 separate projects for test and release versions. It's not recommended to mix up Test data with Production data as it is confusing and Production data may not reflect the real behaviors if test data is in it. For example, if you run Test app every night by installing and uninstalling, it may appear that you have a new user every day in your production app.

您可以做的一件事情是发布该版本的GoogleService-Info.plist,但是使用运行时API来使用自定义FIROptions

One thing you can do is having a GoogleService-Info.plist for the release but use the run-time APIs to use the custom FIROptions

-[FIROptions initWithContentsOfFile:(NSString *)plistPath] 

其中plistPath是自定义GoogleService-Info.plist的路径,例如CustomGoogleService-Info.plist.或者

where plistPath is the path to the custom GoogleService-Info.plist, say CustomGoogleService-Info.plist. Or

- (instancetype)initWithGoogleAppID:(NSString *)googleAppID
                           bundleID:(NSString *)bundleID
                        GCMSenderID:(NSString *)GCMSenderID
                             APIKey:(NSString *)APIKey
                           clientID:(NSString *)clientID
                         trackingID:(NSString *)trackingID
                    androidClientID:(NSString *)androidClientID
                        databaseURL:(NSString *)databaseURL
                      storageBucket:(NSString *)storageBucket
                  deepLinkURLScheme:(NSString *)deepLinkURLScheme;

这样,您可以将其放在用于测试版本的编译器标志下.在发行版中,编译器标记将删除该行,并为发行版使用正确的GoogleService-Info.plist. 例如:

In this way, you can put it under the compiler flag for testing version. In the release, the compiler flag will remove that line and use the correct GoogleService-Info.plist for the release version. For example:

#ifdef TESTING    
FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:pathToCustomPlist];
[FIRApp configureWithOptions:options];
#endif // TESTING

这篇关于适用于单个应用程序的Firebase Analytics(两个项目)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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