SmsRetrieverEffect
Listens once for an SMS that carries the app's hash and delivers its verification code.
Uses the Google SMS Retriever API, which needs no SMS permission. The message must end with the 11-character app hash. The retriever is one-shot: after a code, a timeout, a failure, or a message without a matching code, it stops. Change restartKey (for example when the user taps resend) to listen again. A message without any plausible code delivers nothing and reports no failure. A message whose only plausible code has a different length than length reports SmsRetrieverFailure.CODE_LENGTH_MISMATCH right away.
The code is a whole code, so replace the current input with it: state.cleared().withInput(code). That clears any error and reports completion even when the user had already typed a full code. This effect never logs the message or the code and makes no accessibility announcement; announce the fill or the verification result in the host UI.
This overload accepts numeric codes only. Use the overload with a charset for alphanumeric codes.
Parameters
expected code length; only a standalone digit run of this length is accepted.
called with the digits of the code.
stops listening while false.
a change restarts the listener.
called with the SmsRetrieverFailure reason: SmsRetrieverFailure.TIMEOUT, SmsRetrieverFailure.UNAVAILABLE, or SmsRetrieverFailure.CODE_LENGTH_MISMATCH.
Like the numeric overload, with a charset that decides which codes are recognised.
OtpCharset.NUMERIC accepts a standalone run of exactly OtpLength.digitCount digits. OtpCharset.ALPHANUMERIC accepts a standalone token of exactly that many uppercase letters (A-Z) and digits that contains at least one digit, so K7Q2MX and 482913 match, while lowercase or mixed-case words and letter-only words such as VERIFY never do. Limitation: letter-only codes are not recognised. A token counts as standalone when it is not adjacent to letters, digits, + or /. Two different matching codes are ambiguous and deliver nothing. The code is delivered unchanged; pass it to state.cleared().withInput(code).
Parameters
expected code length.
characters the code may contain; use the field's OtpCharset.
called with the code.
stops listening while false.
a change restarts the listener.
called with the SmsRetrieverFailure reason.