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);
Answer

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.

  • 1
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions