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

codeUpdated method in CodeAutoFill is not called when code is fetched from SMS #249

Open
kosiara opened this issue Jan 14, 2025 · 1 comment

Comments

@kosiara
Copy link

kosiara commented Jan 14, 2025

If we do we usual implementation :

class _OTPDialogState extends ConsumerState<OTPDialog> with CodeAutoFill {
  final codeController = TextEditingController();
  SmsAutoFill? smsAutoFill;

  @override
  void initState() {
    super.initState();
    smsAutoFill = SmsAutoFill();
    smsAutoFill?.getAppSignature.then((signature) {
        smsAutoFill?.listenForCode(smsCodeRegexPattern:  "verification code [0-9]{1,6}");
    });
  }

  @override
  void dispose() {
    codeController.dispose();
    super.dispose();
  }

  @override
  void codeUpdated() {
    // THIS METHOD IS NOT CALLED
  }
}

I'd expect void codeUpdated() {} to be called when a message with a proper code is received. Unfortunately it is not.

Additional info here:
https://stackoverflow.com/a/79355300/706387

Workaround:

As a workaround I'm doing:

    smsAutoFill = SmsAutoFill();
    smsAutoFill?.getAppSignature.then((signature) {
        logger.info("OTP app signature is: $signature");
        smsAutoFill?.listenForCode(smsCodeRegexPattern:  "verification code [0-9]{1,6}");
        smsAutoFill?.code.listen((msg) {
          codeUpdatedWithMsg(msg);
        });
    });
@DharunSanjai
Copy link

Did you solve this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants