mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-23 12:06:47 +08:00
[ios][app] apps initialized natively now automatically initialized js side - via react module getConstants
This commit is contained in:
@@ -21,22 +21,33 @@ export default class FirebaseApp {
|
||||
this._options = Object.assign({}, options);
|
||||
|
||||
// native ios/android to confirm initialized
|
||||
this._intialized = false;
|
||||
this._initialized = false;
|
||||
}
|
||||
|
||||
_initializeApp(local = false) {
|
||||
if (local) {
|
||||
/**
|
||||
*
|
||||
* @param native
|
||||
* @private
|
||||
*/
|
||||
_initializeApp(native = false) {
|
||||
if (native) {
|
||||
// for apps already initialized natively that we have info
|
||||
// from RN constants.
|
||||
// from RN constants
|
||||
this._initialized = true;
|
||||
this._nativeInitialized = true;
|
||||
} else {
|
||||
FirebaseCoreModule.initializeApp(this._name, this._options, (error, result) => {
|
||||
// todo check error/result
|
||||
this._initialized = true;
|
||||
this._nativeInitialized = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {*}
|
||||
*/
|
||||
get name() {
|
||||
if (this._name === INTERNALS.STRINGS.DEFAULT_APP_NAME) {
|
||||
// ios and android firebase sdk's return different
|
||||
@@ -48,12 +59,25 @@ export default class FirebaseApp {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {*}
|
||||
*/
|
||||
get options() {
|
||||
return Object.assign({}, this._options);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {Promise}
|
||||
*/
|
||||
delete() {
|
||||
// todo
|
||||
if (this._name === INTERNALS.STRINGS.DEFAULT_APP_NAME && this._nativeInitialized) {
|
||||
return Promise.reject(
|
||||
new Error('Unable to delete the default native firebase app instance.'),
|
||||
);
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ export default {
|
||||
* @return {string}
|
||||
*/
|
||||
ERROR_APP_NOT_INIT(appName) {
|
||||
return `The [${{ appName }}] firebase app has not been initialized!`;
|
||||
return `The [${appName}] firebase app has not been initialized!`;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user