I'm often reliant on Firebase being initialized before my app can correctly function. The Firebase initializeApp
function appears to have no callback indicating when it has been initialized. Am I right in thinking that initializeApp
is an asynchronous function, and if so how can I set a callback to indicate that it has been initialized before proceeding?

- 8,975
- 13
- 45
- 83
-
The firebase initializeApp() returns a non-null firebase.app.App which is the initialized app. So you can check by using if(firebase.app()) whether youe app is initialized or not and then proceed – Vamsi Krishna May 16 '17 at 09:20
-
Run into same problem. Did you solve this? When I set initialization of my react app into timeout, all work fine. Think your assumption is true that initializeApp is an asynchronous function. But how to handle this? – Jan Franta Jul 20 '17 at 15:42
-
1initializeApp is synchronous, see also this answer : [https://stackoverflow.com/questions/37527247/firebase-initializeapp-callback-promise](https://stackoverflow.com/questions/37527247/firebase-initializeapp-callback-promise) – koma Oct 07 '17 at 11:03
1 Answers
I had the same issues. You can use the Firebase REST API as an alternative. It has nearly all the functions. For example get access token, sign in, signup etc. Guide
Dear Cody Gray you are an amateur developer. Actually this is no library or tool. I am just asking you to use Firebase Rest Api instead of web api. And it is standard rest api from firebase.
Firebase provide both web api and rest api. the rest api can be called and callback function can be invoked on request completed or on response received.
The link i have provided is the complete rest api documentation for the firbase rest api.
Right now you are using web api which is limited.
Please use this rest api from firebase via server side script. for example you can use php curl
$data = array("email" => $_REQUEST['email'], "password" => $_REQUEST['pass'],"returnSecureToken"=>"true");
$data_string = json_encode($data);
$ch = curl_init('https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=AIzaSyB1fIfESmR6DAUJ24X70ch2xEpi9BfF_sE');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
So you can save this script like login.php
then make a http request either via javascipt, jquery , ajax , or an language. and on http response just do what ever the task you want to do after authentication or signup or signin .
the guide i send you have all the list of api's . You can use according to your need.
Again this is no tool or library . This is standard firebase rest api.

- 1
- 1