chemerisuk / cordova-plugin-firebase-authentication

Cordova plugin for Firebase Authentication
MIT License
98 stars 60 forks source link

Cannot create PhoneAuthCredential without either verificationProof, sessionInfo, or temprary proof #93

Closed itshazlan closed 4 years ago

itshazlan commented 4 years ago

Hi, last time I've tested the app is still giving me the verification code. But lately, it returns error Can not create PhoneAuthCredential without either verificationProof, sessionInfo, or temporary proof

Here is my code:

    this.firebaseAuth.verifyPhoneNumber(JSON.stringify(loginData.phone_number), 1 * 60 * 1000)
      .then((verificationID) => {
        console.log('verificationID: ', verificationID);
        this.verificationID = verificationID;
        this.presentModal(this.verificationID, loginData);
      });

To verification with code:

  signInWithCode() {
    let code: any = {
      verificationID: this.verificationID,
      verificationCode: this.verificationCode
    };
    console.log(code);
    this.firebaseAuth.signInWithVerificationId(code.verificationID, code.verificationId)
      .then(user => {
        console.log('user: ', JSON.stringify(user));
        this.apiService.loginUser(this.loginData)
          .then((response) => {
            console.log(JSON.stringify(response));
            this.storage.set('phoneNumber', this.loginData.phone_number);
            this.modalCtrl.dismiss();
            this.navCtrl.navigateForward('/home');
          });
      })
      .catch((error) => {
        console.log('error: ', JSON.stringify(error));
        this.modalCtrl.dismiss();
        this.apiService.logoutUser();
        this.apiService.presentAlert('Perhatian', 'Verifikasi gagal. Silahkan coba lagi.');
      });
  }

The thing that I do afterward is re-checking the SHA on the firebase settings, run cordova clean android but didn't give me the solution. If anyone had to experience on this issue, please help me. Thank you.

itshazlan commented 4 years ago

Closed. Because the SMS Code that given to call the signInWithVerificationId method is undefined or null.