You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge branch 'master' of github.com:fullstackreact/react-native-firestack
* 'master' of github.com:fullstackreact/react-native-firestack:
Cleanup listeners and add a little bit of documentation
Remove auth methods from instance root & update documentation
Fix Java Database Listeners
Fix listeners getting called when it's not their turn
Android: Fix .on() listeners not getting removed / called immediately on setup
Upgrade google play services and firebase to 9.8.0
Android: fix userMap not being used in userCallback & anonymousUserCallback
Fix passedUser not being used, make it more clear what user is being used
Copy file name to clipboardExpand all lines: README.md
+14-12
Original file line number
Diff line number
Diff line change
@@ -280,12 +280,14 @@ All methods return a promise.
280
280
281
281
Firestack handles authentication for us out of the box, both with email/password-based authentication and through oauth providers (with a separate library to handle oauth providers).
282
282
283
+
> Android requires the Google Play services to installed for authentication to function.
284
+
283
285
#### listenForAuth()
284
286
285
287
Firebase gives us a reactive method for listening for authentication. That is we can set up a listener to call a method when the user logs in and out. To set up the listener, call the `listenForAuth()` method:
We can remove this listener by calling the `unlistenForAuth()` method. This is important to release resources from our app when we don't need to hold on to the listener any longer.
307
309
308
310
```javascript
309
-
firestack.unlistenForAuth()
311
+
firestack.auth.unlistenForAuth()
310
312
```
311
313
312
314
#### createUserWithEmail()
313
315
314
316
We can create a user by calling the `createUserWithEmail()` function. The `createUserWithEmail()` accepts two parameters, an email and a password.
We can update the current user's password using the `updateUserPassword()` method. It accepts a single parameter: the new password for the current user
To send a password reset for a user based upon their email, we can call the `sendPasswordResetWithEmail()` method. It accepts a single parameter: the email of the user to send a reset email.
.then(res=>console.log('Check your inbox for further instructions'))
422
424
.catch(err=>console.error('There was an error :('))
423
425
```
@@ -431,7 +433,7 @@ It accepts a single parameter:
431
433
* object which contains updated key/values for the user's profile. Possible keys are listed [here](https://firebase.google.com/docs/auth/ios/manage-users#update_a_users_profile).
432
434
433
435
```javascript
434
-
firestack.updateUserProfile({
436
+
firestack.auth.updateUserProfile({
435
437
displayName:'Ari Lerner'
436
438
})
437
439
.then(res=>console.log('Your profile has been updated'))
@@ -443,7 +445,7 @@ firestack.updateUserProfile({
443
445
It's possible to delete a user completely from your account on Firebase. Calling the `deleteUser()` method will take care of this for you.
444
446
445
447
```javascript
446
-
firestack.deleteUser()
448
+
firestack.auth.deleteUser()
447
449
.then(res=>console.log('Sad to see you go'))
448
450
.catch(err=>console.error('There was an error - Now you are trapped!'))
449
451
```
@@ -453,7 +455,7 @@ firestack.deleteUser()
453
455
If you want user's token, use `getToken()` method.
454
456
455
457
```javascript
456
-
firestack.getToken()
458
+
firestack.auth.getToken()
457
459
.then(res=>console.log(res.token))
458
460
.catch(err=>console.error('error'))
459
461
```
@@ -463,7 +465,7 @@ firestack.getToken()
463
465
To sign the current user out, use the `signOut()` method. It accepts no parameters
464
466
465
467
```javascript
466
-
firestack.signOut()
468
+
firestack.auth.signOut()
467
469
.then(res=>console.log('You have been signed out'))
Although you _can_ get the current user using the `getCurrentUser()` method, it's better to use this from within the callback function provided by `listenForAuth()`. However, if you need to get the current user, call the `getCurrentUser()` method:
474
476
475
477
```javascript
476
-
firestack.getCurrentUser()
478
+
firestack.auth.getCurrentUser()
477
479
.then(user=>console.log('The currently logged in user', user))
0 commit comments