Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import { StyleSheet, Text, View, AsyncStorage } from "react-native";
- import { Container, Content, Form, Input, Item, Button, Label } from 'native-base'
- import * as firebase from 'firebase';
- import { Permissions, Notifications } from 'expo';
- export default class Login extends React.Component {
- constructor(props){
- super(props)
- this.state = ({
- email: '',
- password: ''
- })
- }
- registerForPushNotificationsAsync = async (user) => {
- // Here I have few Expo related 'await' operations returning notification token from expo
- }
- // ...........
- loginUser = (email, password) => {
- try{
- firebase.auth().signInWithEmailAndPassword(email, password).then(function(user){
- this.registerForPushNotificationsAsync(user);
- })
- }
- catch(error){
- console.log(error.toString())
- }
- }
- render() {
- return (
- <Container style={styles.container}>
- <Form>
- // .......
- <Button style={{marginTop: 10}}
- full
- rounded
- success
- onPress={()=>this.loginUser(this.state.email, this.state.password)}
- >
- <Text style={styles.inputButtonsText}>Login</Text>
- </Button>
- // ......
- </Form>
- </Container>
- );
- }
- }
- this.registerForPushNotificationsAsync(user);
Add Comment
Please, Sign In to add comment