skip to Main Content

The major problem is coming that OTP verification is not Responding the same way its responding on debug mode. even its working on play store for test numbers

@override
  Future checkOtp(String verificationId, String smsCode) async{
    try{
      showLoadingDialog();
      PhoneAuthCredential credential = PhoneAuthProvider.credential(verificationId: verificationId, smsCode: smsCode);
      var result = await _auth.signInWithCredential(credential)
          .then((value) {
            var user = value.user;
            if (kDebugMode) {
              print(user);
              print(value);
            }
            if (value.additionalUserInfo?.isNewUser == true) {
              Get.offNamed( RouteName.infoScreen,arguments: {
                "user":user
              });
            } else {
              Get.offNamed( RouteName.homeScreen,arguments: {
                "user":user
              });
              Utils.snackBar("Successfull", "Congrats on your successfully registration");

      }      return value;
          });
      return result;
    } catch(e){
      hideLoadingDialog();
      handler.handleFirebaseLoginErrors(e);
      bool result = false;
      if(e.toString()=="[firebase_auth/invalid-verification-code] The verification code from SMS/TOTP is invalid. Please check and enter the correct verification code again.") {
        Utils.snackBar("Invalid Otp", "Please Try with another otp.");
        result = true;
      }
      return result;
    }
  }`


This is my fucntion

I have already place all the SHA1 and SHA256 key from play store as well as from android studio.
in emulator its working perfect. even i cant find anything in logs expect this –

07:43:12.501 12725-12806 mali_winsys             com.updevelop.wellness_z_mvvm        D  EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
2023-11-18 07:43:14.466 12725-12806 Surface                 com.updevelop.wellness_z_mvvm        D  Surface::disconnect(this=0x7a2bece000,api=1)
2023-11-18 07:43:14.469 12725-12725 View                    com.updevelop.wellness_z_mvvm        D  [Warning] assignParent to null: this = android.widget.FrameLayout{65c5d03 V.E...... ......ID 0,0-690,137}
2023-11-18 07:43:14.469  1332-1332  WindowManager           system_server                        V  mCurrentFocus: Window{ae17056 u0 com.updevelop.wellness_z_mvvm/com.updevelop.wellness_z_mvvm.MainActivity} newFocus Window{ae17056 u0 com.updevelop.wellness_z_mvvm/com.updevelop.wellness_z_mvvm.MainActivity}

when i try through google play store app.

2

Answers


  1. Chosen as BEST ANSWER

    I have found the issue , the issue was in Automatic code detection from the devise. When OTP was automatically Detected then Manual OTP Was not working that is check OTP Function. you need to Navigate from Verification Complete in the function while you first send mobile number for verifications


  2. I faced the same issue before, and spent about 3 days exploring why!

    your code is working fine, i don’t see any issues, however, i fixed mine by "Just delete the app from Simulator / Emulator and rebuild the App again" and then check the OTP

    if still doesn’t work, double check that you used the correct SHA certificates for both Debug and Release modes

    and one more important thing
    Double-check that you have added the correct SHA-1 or SHA-256 fingerprint of your release keystore to the Firebase console.

    and make sure to replace the new google-services.json file with the old one

    The most important step is "Don’t test the OTP without deleting the app and rebuild it, until you get the OTP code" then you can test it without keep deleting it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search