@@ -916,12 +916,13 @@ firebase.login = function (arg) {
916916
917917 var OnVerificationStateChangedCallbacks = com . google . firebase . auth . PhoneAuthProvider . OnVerificationStateChangedCallbacks . extend ( {
918918 onVerificationCompleted : function ( phoneAuthCredential ) {
919+ console . log ( "phone number verification completed" ) ;
919920 firebase . _verifyPhoneNumberInProgress = false ;
920921 // the user previously authenticated with phone (or no prompt was required), so sign in and complete
921922 firebaseAuth . signInWithCredential ( phoneAuthCredential ) . addOnCompleteListener ( onCompleteListener ) ;
922923 } ,
923924 onVerificationFailed : function ( firebaseException ) {
924- console . log ( "onVerificationStateChangedCallbacks.onVerificationFailed: " + firebaseException )
925+ console . log ( "onVerificationStateChangedCallbacks.onVerificationFailed: " + firebaseException ) ;
925926 firebase . _verifyPhoneNumberInProgress = false ;
926927 var errorMessage = firebaseException . getMessage ( ) ;
927928 if ( errorMessage . indexOf ( "INVALID_APP_CREDENTIAL" ) > - 1 ) {
@@ -931,21 +932,14 @@ firebase.login = function (arg) {
931932 }
932933 } ,
933934 onCodeSent : function ( verificationId , forceResendingToken ) {
934- // TODO these are printed, but need to run on a device with a mathing phonenr of course..
935- console . log ( "onVerificationStateChangedCallbacks.onCodeSent.verificationId: " + verificationId )
936- console . log ( "onVerificationStateChangedCallbacks.onCodeSent.forceResendingToken: " + forceResendingToken )
937-
938- // in some cases the prompt is not required, and onVerificationCompleted is called immediately.. not sure about the timing, so using a short timeout
935+ // If the device has a SIM card auto-verification may occur in the background (eventually calling onVerificationCompleted)
936+ // .. so the prompt would be redundant, but it's recommended by Google not to wait to long before showing the prompt
939937 setTimeout ( function ( ) {
940938 if ( firebase . _verifyPhoneNumberInProgress ) {
941939 firebase . _verifyPhoneNumberInProgress = false ;
942-
943940 firebase . requestPhoneAuthVerificationCode ( function ( userResponse ) {
944- console . log ( "onVerificationStateChangedCallbacks com.google.firebase.auth.PhoneAuthCredential: " + com . google . firebase . auth . PhoneAuthCredential )
945- var authCredential = com . google . firebase . auth . PhoneAuthCredential . getCredential ( verificationId , userResponse ) ;
946- console . log ( "onVerificationStateChangedCallbacks authCredential: " + authCredential )
941+ var authCredential = com . google . firebase . auth . PhoneAuthProvider . getCredential ( verificationId , userResponse ) ;
947942 var user = com . google . firebase . auth . FirebaseAuth . getInstance ( ) . getCurrentUser ( ) ;
948- console . log ( "onVerificationStateChangedCallbacks user: " + user )
949943 if ( user ) {
950944 if ( firebase . _alreadyLinkedToAuthProvider ( user , "phone" ) ) {
951945 firebaseAuth . signInWithCredential ( authCredential ) . addOnCompleteListener ( onCompleteListener ) ;
@@ -955,9 +949,9 @@ firebase.login = function (arg) {
955949 } else {
956950 firebaseAuth . signInWithCredential ( authCredential ) . addOnCompleteListener ( onCompleteListener ) ;
957951 }
958- } ) ;
952+ } , arg . phoneOptions . verificationPrompt ) ;
959953 }
960- } , 1000 ) ;
954+ } , 3000 ) ;
961955 }
962956 } ) ;
963957
0 commit comments