Sathya Raj
Sathya Raj

Reputation: 1089

How to Invoke Firebase in Reactnative app?

I am trying to use Firebase Email and password sign in method to create login for my app. when i try to invoke createUserWithEmailAndPassword or signInWithEmailAndPassword these method are not getting invoked. How to verify firebase method invocation in reactnative.

<Button onPress={this.onButtonPress.bind(this)}>Log In</Button> 

onButtonPress(){
    const { email, password } = this.state;

    this.setState({error: ''});
    console.log(email + ' ' + password); //==> this executes
    firebase.auth().signInWithEmailAndPassword(email, password)
    .then(function(){
      console.log('sign insuccess'); //==> no execution
    })
    .catch(() => {
      firebase.auth().createUserWithEmailAndPassword(email, password)
      .then(function(){
        console.log('create user success'); //==> no execution
      })
      .catch(() => {
        this.setState({ error: 'Authentication Failed.' }); //==> no execution
      });
    });
    console.log('buttonpress finished'); 
}

error console

Upvotes: 0

Views: 129

Answers (1)

Kishan Gujarati
Kishan Gujarati

Reputation: 985

you should try this it's worked for me, hope it'll help you

try signInAndRetrieveDataWithEmailAndPassword instead of signInWithEmailAndPassword

edited

signInAndRetrieveDataWithEmailAndPassword is deprecated now, so you should use signInWithEmailAndPassword otherwise you'll get error.

thank you @mshikher .

Upvotes: 1

Related Questions