Matej Vida
Matej Vida

Reputation: 31

Can two different Firebase project be used in one Android app, specifically crashlytics, messaging and performance extensions

For a couple of reasons we had to use multiple Firebase projects in one app. At the moment we have implemented auth extension to user one Firebase project and via code initialisation and crashlytics, performance and messaging to use another via the config file. We would like to make crashlytics and performance extensions to use the project that the auth extension uses and messaging to use the same one that it uses now.

I went through some initialisation examples but could not find anything related to crashlytics or performance extensions.

This is how I initialise different project for auth extension.

// credentials for auth project on Firebase
        final String authAppName = BuildConfig.AUTH_APP_NAME;
        final String authAppApplicationId = BuildConfig.AUTH_APPLICATION_ID;
        final String authAppApiKey = BuildConfig.AUTH_APPLICATION_KEY;

        List<FirebaseApp> listOfActiveApps = FirebaseApp.getApps(context);
        if (!listOfActiveApps.isEmpty()) {
            for (FirebaseApp app : listOfActiveApps) {
                if (authAppApiKey.equals(app.getOptions().getApiKey())) {
                    return app;
                }
            }
        }

        FirebaseOptions options = new FirebaseOptions.Builder()
                .setApplicationId(authAppApplicationId)
                .setApiKey(authAppApiKey)
                .build();

        return FirebaseApp.initializeApp(context, options, authAppName);

Upvotes: 3

Views: 227

Answers (1)

Kevin Kokomani
Kevin Kokomani

Reputation: 1616

Fabric/Firebaser here, great question - this behavior is generally not supported today, due to the way Crashlytics and Performance need to initialize, particularly when mixed with Auth.

Upvotes: 2

Related Questions