[ios][app] apps initialized natively now automatically initialized js side - via react module getConstants

This commit is contained in:
Salakar
2017-07-17 18:20:27 +01:00
parent 9a3e22431b
commit 813b91f5ad
3 changed files with 63 additions and 11 deletions

View File

@@ -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();
}

View File

@@ -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!`;
},
/**