Use 2 different firebase projects for FCM and Crashlytics with android

老子叫甜甜 提交于 2020-12-06 15:57:10

问题


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.

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.

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")

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.


回答1:


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.



来源:https://stackoverflow.com/questions/64373296/use-2-different-firebase-projects-for-fcm-and-crashlytics-with-android

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