ashinga48 / React-Native-Firebase-Phone-Authentication

Seems there's not a proper react native plugin with phone authentication alone. So creating it.
9 stars 6 forks source link

RNFirebasePhoneauth is not defined #1

Open eman1000 opened 7 years ago

eman1000 commented 7 years ago

hie my setup up is like this

import RNFirebasePhoneAuth from "react-native-firebase-phone-auth";
import firebase from './firebase';

class LoginPhone extends React.Component{
  componentDidMount() {
     this.listenToOTP()
  }
  listenToOTP(){

         DeviceEventEmitter.addListener('OTPStatus', (data) => {

             switch(data.CODE){
                case "SENT":
                        //SMS Sent
                    break;
                case "VERIFIED":
                         //SMS Received & read by google play services
                          let authData = {
                              code : data.OTPNumber,
                              verificationId : data.verificationId
                          }
                          firebase.auth().signInWithPhoneAuth(
                             authData, 
                             (success)=>{ 
                                 //on Successful Login
                             }, 
                             (error)=>{ 
                                 //on Error 
                             });
                     break;
                case "ERROR":
                        //error sending SMS
                    break;
             }

             if(data.CODE == "ERROR")
                 {
                 }

         });

     }
     onPressSendOTP(){
          let phoneNumber = "+60166*****";
          RNFirebasePhoneauth.sendOTP(phoneNumber);
     }

I am getting an error "RNFirebasePhoneauth is no defined "

ashinga48 commented 7 years ago

Will look into it and update

eman1000 commented 7 years ago

@ashinga48 ok thanks

MakeApps commented 7 years ago

Not working....

ButhSitha commented 7 years ago

Not working...

wmonecke commented 6 years ago

First of all there is a clear typo:

You import RNFirebasePhoneAuth but use RNFirebasePhoneauth.

However I tried with the typo corrected and this package is still not working. Please update or tell people that it is not usable!

@ashinga48 I think this package has a lot of potential. Are you planning on updating it?

ashinga48 commented 6 years ago

@wmonecke thank you, i will update asap. did you try installing with npm. it has the updated version.

hkumar2harman commented 6 years ago

when calling RNFirebasePhoneauth.sendOTP(phoneNumber); giving error:- RNFirebasePhoneAuth.sendOTP got 1 argument, expected 3.

ashinga48 commented 6 years ago

You need to pass callbacks Success and failure ( can be empty atleast )

RNFirebasePhoneauth.sendOTP(phoneNumber, (success)=>{}, (error)=>{} );