Replies: 1 comment 1 reply
-
As background information, react-native-firebase is a wrapper to the native firebase-android-sdk and firebase-ios-sdk, and as a wrapper it is as thin as possible. The primary goal is to expose those native SDKs to the react-native ecosystem, with an API as close as possible to the firebase-js-sdk (since react-native is javascript...) but while also exposing the extra native capabilities having truly native SDKs (versus just javascript). So that's the goal of the package. That also brings constraints (since the native SDKs do have some constraints) First constraint: the native SDKs require the primary firebase app ( At application startup in the native code (before the react-native javascript layer even exists) the Firebase system starts, reads that configuration information, creates the default app and starts doing useful things like 1) monitoring for crashes with crashlytics, 2) instrumenting for performance, 3) measuring for analytics, 4) listening for initial startup notifications and messages and links - these are all native activities that you get with the native SDKs that the JS SDK does not provide. Okay, so javascript context does not exist yet but we already have our primary / default app configured and Firebase is running. Now react-native finishes booting up and initializing and you finally get the chance to start running your react-native javascript project code. What can you do? Well, if you like, since we do have the power of the native SDKs, you may have some other firebase project configured via XML and you may load that as a secondary app. Those are the APIs you mention. Your questions:
Hope this helps |
Beta Was this translation helpful? Give feedback.
-
Description:
I have been reviewing the source code for the
ReactNativeFirebaseApp
class in the Firebase library for React Native, and I've come across an interesting design choice involving theinitializeSecondaryApp
functions. There are two versions of this function with slightly different signatures, and I'm seeking clarification on the reasoning behind this design.In the provided source code, there are the following two
initializeSecondaryApp
functions:initializeSecondaryApp(String name)
:applicationContext
that was previously set using thesetApplicationContext
method.FirebaseOptions.fromResource(applicationContext)
to obtain configuration options for the secondary app.initializeSecondaryApp(String name, Context applicationContext)
:applicationContext
.applicationContext
if needed.FirebaseOptions.fromResource(applicationContext)
to obtain configuration options for the secondary app.My questions are as follows:
initializePrimaryApp
)?I believe that understanding the purpose of these two
initializeSecondaryApp
functions and the automatic initialization process, if it exists, would be valuable for developers working with Firebase in a React Native environment. It can help ensure proper configuration and usage of Firebase within our apps.Beta Was this translation helpful? Give feedback.
All reactions