Use multiple firebase accounts in single android app for google analytics

前端 未结 2 484
不思量自难忘°
不思量自难忘° 2020-12-02 23:48

I have a use case in which 1 app will be used by multiple separate companies (franchises) that will have their own marketing and management teams. I need the user to select

2条回答
  •  既然无缘
    2020-12-03 00:32

    It's possible to have multiple Firebase instance in your apps

    FirebaseOptions options = new FirebaseOptions.Builder()
       .setApplicationId("Your AppId") // Required for Analytics.
       .setApiKey("You ApiKey") // Required for Auth.
       .setDatabaseUrl("Your DB Url") // If you wanted to
       .build();
    
    FirebaseApp.initializeApp(context, options, "CompanyA");
    

    Which you can get Firebase instances by

    FirebaseApp appCompanyA = FirebaseApp.getInstance("CompanyA");
    

    You can see the full example use of Auth and Realtime Database using multiple Firebase instance here

    I'll leave this solution here which may duplicate with another answers for someone who might need this

    Hope this help :)

提交回复
热议问题