Guest User

Untitled

a guest
Nov 7th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { StyleSheet, Text, View, AsyncStorage } from "react-native";
  3. import { Container, Content, Form, Input, Item, Button, Label } from 'native-base'
  4.  
  5. import * as firebase from 'firebase';
  6.  
  7. import { Permissions, Notifications } from 'expo';
  8.  
  9. export default class Login extends React.Component {
  10. constructor(props){
  11. super(props)
  12.  
  13. this.state = ({
  14. email: '',
  15. password: ''
  16. })
  17. }
  18.  
  19. registerForPushNotificationsAsync = async (user) => {
  20. // Here I have few Expo related 'await' operations returning notification token from expo
  21. }
  22.  
  23. // ...........
  24.  
  25. loginUser = (email, password) => {
  26. try{
  27. firebase.auth().signInWithEmailAndPassword(email, password).then(function(user){
  28. this.registerForPushNotificationsAsync(user);
  29. })
  30. }
  31. catch(error){
  32. console.log(error.toString())
  33. }
  34. }
  35.  
  36. render() {
  37. return (
  38. <Container style={styles.container}>
  39. <Form>
  40. // .......
  41. <Button style={{marginTop: 10}}
  42. full
  43. rounded
  44. success
  45. onPress={()=>this.loginUser(this.state.email, this.state.password)}
  46. >
  47. <Text style={styles.inputButtonsText}>Login</Text>
  48. </Button>
  49. // ......
  50. </Form>
  51. </Container>
  52. );
  53. }
  54. }
  55.  
  56. this.registerForPushNotificationsAsync(user);
Add Comment
Please, Sign In to add comment