在Android中将2个不同的Firebase项目用于FCM和Crashlytics [英] Use 2 different firebase projects for FCM and Crashlytics with android

查看:29
本文介绍了在Android中将2个不同的Firebase项目用于FCM和Crashlytics的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试在Android中使用2个不同的Firebase项目,一个用于FCM,另一个用于Crashlytics(例如,针对FCM的ProjectA和针对Crashlytics的ProjectB).但这对我不起作用.

I am trying to use 2 different Firebase projects with android, one for FCM and another for Crashlytics(say ProjectA for FCM and ProjectB for Crashlytics). But it's not working for me.

我正在手动初始化Firebase.我的应用启动后,便立即使用ProjectA配置为FCM初始化Firebase.

I am initialising Firebase manually. As soon as my app starts I initialise Firebase for FCM using ProjectA configuration.

val options = FirebaseOptions.Builder()
            .setProjectId(fcmOptions[5]!!)
            .setApplicationId(fcmOptions[0]!!) 
            .setApiKey(fcmOptions[1]!!) 
            .setDatabaseUrl(fcmOptions[2]) 
            .setGcmSenderId(fcmOptions[3])
            .setStorageBucket(fcmOptions[4])
            .build()

FirebaseApp.initializeApp(this, options)

直到这里很好,令牌已生成并且我能够接收推送通知.

Till here it is fine, the token gets generated and I am able to receive Push notifications.

单击此按钮后,我使用ProjectB配置注册了Crashlytics.

After this on click of a button I register for Crashlytics using ProjectB configuration.

val options = FirebaseOptions.Builder()
            .setProjectId(crashlyticsOptions[5]!!)
            .setApplicationId(crashlyticsOptions[0]!!) 
            .setApiKey(crashlyticsOptions[1]!!) 
            .setDatabaseUrl(crashlyticsOptions[2]) 
            .setStorageBucket(crashlyticsOptions[4])
            .build()

FirebaseApp.initializeApp(this, options, "crashlytics")

在此步骤之后,我导致了几次崩溃,以便可以在Crashlytics仪表板中看到崩溃.这里的问题是,崩溃没有出现在我期望的ProjectB Crashlytics控制台下.但是崩溃出现在FCM的ProjectA下.

After this step I cause a few crashes so that I can see the crashes in Crashlytics dashboard. The problem here is that the crashes don't appear under ProjectB Crashlytics console which is what I expect. But the crashes appear under the ProjectA for FCM.

以前有没有人尝试过这种情况,可以帮助我.

Has anyone tried such scenario before and can help me out.

推荐答案

Crashlytics不支持使用辅助项目来捕获崩溃.它将仅使用默认项目(您初始化时没有名称的项目).FCM和Analtyics的方法相同.

Crashlytics does not support using a secondary project to capture crashes. It will only use the default project (the one you initialized without a name). FCM and Analtyics are the same way.

这篇关于在Android中将2个不同的Firebase项目用于FCM和Crashlytics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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