This repository was archived by the owner on Apr 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +40
-1
lines changed
Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -223,11 +223,50 @@ but if you only want to wipe everything at '/users', do this:
223223```
224224
225225### login
226- v 1.1.0 of this plugin adds the capability to log your users in. Either anonymously or by email and password.
226+ v 1.1.0 of this plugin adds the capability to log your users in, either
227+
228+ * anonymously,
229+
230+ * by email and password or
231+
232+ * using a custom token.
233+
227234You need to add support for those features in your Firebase instance at the 'Login & Auth' tab.
228235
229236You can expect more login mechanisms to be added in the future.
230237
238+ #### Listening to auth state changes
239+ As stated [ here] ( https://firebase.google.com/docs/auth/ios/manage-users#get_the_currently_signed-in_user )
240+
241+ > The recommended way to get the current user is by setting a listener on the Auth object
242+
243+ To listen to auth state changes you can register a listener like this:
244+
245+ ``` js
246+ var listener = {
247+ onAuthStateChanged : function (data ) {
248+ console .log (data .loggedIn ? " Logged in to firebase" : " Logged out from firebase" );
249+ if (data .loggedIn ) {
250+ console .log (" User info" , data .user );
251+ }
252+ },
253+ thisArg: this
254+ };
255+
256+ firebase .addAuthStateListener (listener);
257+ ```
258+
259+ To stop listening to auth state changed:
260+
261+ ``` js
262+ firebase .removeAuthStateListener (listener);
263+ ```
264+
265+ To check if already listening to auth state changes
266+ ``` js
267+ firebase .removeAuthStateListener (listener);
268+ ```
269+
231270#### Anonymous login
232271``` js
233272 firebase .login ({
You can’t perform that action at this time.
0 commit comments