SmsUserConsentEffect
Listens once for an SMS and, after the user allows it, delivers its verification code.
Uses the Google SMS User Consent API, which needs no SMS permission and no app hash in the message. When a matching message arrives, Google shows a consent prompt (a system dialog); the effect then receives only that one message if the user taps Allow. The effect is one-shot: after a code, a failure, or a message without a matching code, it stops. A result from a superseded session (any input or enabled changed while the prompt was open) or a disabled effect is ignored. Recreating the activity keeps the session, so it neither listens again nor reports a second outcome. 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 SmsUserConsentFailure.CODE_LENGTH_MISMATCH.
The code is a whole code, so replace the current input with it: state.cleared().withInput(code). This effect never logs the message or the code, draws no UI of its own, never moves focus, and makes no accessibility announcement.
Accessibility host responsibilities: the consent prompt is a system dialog that takes focus and TalkBack reads it; when it closes, the system returns focus to the activity, so keep the OTP field where it is and do not steal focus. Announce the fill or the verification result in the host UI, and explain SmsUserConsentFailure.DENIED and SmsUserConsentFailure.TIMEOUT with visible text plus the resend action. If the app is in the background when the message arrives, the prompt is held until the host lifecycle is at least STARTED.
Do not enable this together with SmsRetrieverEffect; use one of them per screen. The host must be a ComponentActivity (any Compose host with an activity result registry).
Parameters
expected code length; only a standalone run of this length is accepted.
called with the code, in the field's charset.
characters the code may contain; use the field's OtpCharset.
stops listening while false.
a change restarts the listener.
restricts the prompt to messages from this number; null accepts any sender (Google never offers messages from senders in the user's contacts).
called with the SmsUserConsentFailure reason.