Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] OTP Autofill Not Detected While Phone Number is Detected #100

Open
4 tasks done
bhanuka96 opened this issue Sep 5, 2024 · 1 comment
Open
4 tasks done

[BUG] OTP Autofill Not Detected While Phone Number is Detected #100

bhanuka96 opened this issue Sep 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@bhanuka96
Copy link

bhanuka96 commented Sep 5, 2024

Expected Behavior

The OTP autofill feature should detect and automatically populate the OTP code when it is received.

Actual Behavior

The phone number is detected successfully, but the OTP is not automatically detected or populated in the app. I tried both startListenUserConsent and startListenRetriever

Steps to Reproduce

  1. Set up OTP autofill using OTPTextEditController.
  2. Phone number detection works as expected.
  3. Receive OTP but it is not detected or autofilled into the OTP input field.

Details

  • Flutter version: Channel stable, 3.24.1
  • Platform: Android/iOS
  • macOS version: macOS 14.6.1 (23G93 darwin-arm64)
  • Android Studio: version 2024.1
  • Xcode version: 15.4
  • VS Code version: 1.92.2
  • Android SDK version: 32.1.0-rc1

Sample SMS

Your Firebase App verification code is 123456
signature_code_here

Full Code

class PhoneDetector {
  final OTPInteractor _otpInteractor = OTPInteractor();
  late OTPTextEditController controller;

  void detectPhoneNumber() {
      _otpInteractor.hint.then(phoneDetector);
  }

  void getSignature() {
      _otpInteractor.getAppSignature().then((signature) {
        debugPrint('Your app signature:$signature');
      });
  }

  void phoneDetector(String? value) {
      final _phone = value.getMobileNumberAuto(countryCode);
  }

  void listenForCode() {
      controller = OTPTextEditController(
        codeLength: 6,
        onCodeReceive: (code) {
          if (code.isEmpty) return;
          codeUpdated(code);
        },
        otpInteractor: _otpInteractor,
        onTimeOutException: () {
          controller.startListenRetriever(
            (code) {
              final exp = RegExp(r'(\d{6})');
              return exp.stringMatch(code ?? '') ?? '';
            },
          );
        },
      )..startListenRetriever(
          (code) {
            final exp = RegExp(r'(\d{6})');
            return exp.stringMatch(code ?? '') ?? '';
          },
        );
  }

  // @override
  void codeUpdated(String code) {
      debugPrint('SMS AUTOFILL CODE:$code');
  }

  void detectorDispose() {
      controller.stopListen();
  }
}

What Did You Try to Solve

  • Verified that phone number detection works.
  • Checked the listenForCode method implementation.
  • Attempted changing configurations and testing on different devices.

Checklist for Self-Check

  • Added expected and actual behavior.
  • Added an isolated way to reproduce the bug.
  • Specified Flutter, Dart version, and platform.
  • All unspecified fields in the issue description are deleted.
@bhanuka96 bhanuka96 added the bug Something isn't working label Sep 5, 2024
Copy link

github-actions bot commented Sep 5, 2024

Link to Pyrus task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant