SmsCodeRetriever

class SmsCodeRetriever


SmsCodeRetriever is a variant of SmsRetriever, and it provides access to Google services that help you retrieve SMS verification codes sent to the user's device, without having to ask for android.permission.READ_SMS or android.permission.RECEIVE_SMS.

To use SmsCodeRetriever in the Android autofill service, obtain an instance of using getAutofillClient or getAutofillClient, and start SMS Code Retriever service by calling startSmsCodeRetriever. To use it in the browser app, you obtain an instance of SmsCodeBrowserClient using getBrowserClient or getBrowserClient instead.

The service first looks for an SMS verification code from messages recently received (up to 1 minute prior). If there is no SMS verification code found from the SMS inbox, it waits for new incoming SMS messages until it finds an SMS verification code or reaches the timeout (about 5 minutes).

Summary

Constants

const String!
EXTRA_SMS_CODE = "com.google.android.gms.auth.api.phone.EXTRA_SMS_CODE"

Intent extra key of the retrieved SMS verification code by the SmsCodeAutofillClient.

const String!
EXTRA_SMS_CODE_LINE = "com.google.android.gms.auth.api.phone.EXTRA_SMS_CODE_LINE"

Intent extra key of the retrieved SMS verification code line by SmsCodeBrowserClient.

const String!
EXTRA_STATUS = "com.google.android.gms.auth.api.phone.EXTRA_STATUS"

Intent extra key of Status, which indicates RESULT_SUCCESS, RESULT_TIMEOUT or SmsRetrieverStatusCodes.

const String!
SMS_CODE_RETRIEVED_ACTION = "com.google.android.gms.auth.api.phone.SMS_CODE_RETRIEVED"

Intent action when an SMS verification code is retrieved.

Public functions

java-static SmsCodeAutofillClient!

Creates a new instance of SmsCodeAutofillClient for use in an Activity.

java-static SmsCodeAutofillClient!

Creates a new instance of SmsCodeAutofillClient for use in a Context.

java-static SmsCodeBrowserClient!

Creates a new instance of SmsCodeBrowserClient for use in an Activity.

java-static SmsCodeBrowserClient!

Creates a new instance of SmsCodeBrowserClient for use in a Context.

Constants

EXTRA_SMS_CODE

const val EXTRA_SMS_CODE = "com.google.android.gms.auth.api.phone.EXTRA_SMS_CODE": String!

Intent extra key of the retrieved SMS verification code by the SmsCodeAutofillClient.

EXTRA_SMS_CODE_LINE

const val EXTRA_SMS_CODE_LINE = "com.google.android.gms.auth.api.phone.EXTRA_SMS_CODE_LINE": String!

Intent extra key of the retrieved SMS verification code line by SmsCodeBrowserClient.

EXTRA_STATUS

const val EXTRA_STATUS = "com.google.android.gms.auth.api.phone.EXTRA_STATUS": String!

Intent extra key of Status, which indicates RESULT_SUCCESS, RESULT_TIMEOUT or SmsRetrieverStatusCodes.

SMS_CODE_RETRIEVED_ACTION

const val SMS_CODE_RETRIEVED_ACTION = "com.google.android.gms.auth.api.phone.SMS_CODE_RETRIEVED": String!

Intent action when an SMS verification code is retrieved.

Public functions

getAutofillClient

java-static fun getAutofillClient(activity: Activity!): SmsCodeAutofillClient!

Creates a new instance of SmsCodeAutofillClient for use in an Activity. This SmsCodeAutofillClient is intended to be used by the current user-designated autofill service only.

getAutofillClient

java-static fun getAutofillClient(context: Context!): SmsCodeAutofillClient!

Creates a new instance of SmsCodeAutofillClient for use in a Context. This SmsCodeAutofillClient is intended to be used by the current user-designated autofill service only.

getBrowserClient

java-static fun getBrowserClient(activity: Activity!): SmsCodeBrowserClient!

Creates a new instance of SmsCodeBrowserClient for use in an Activity. This SmsCodeBrowserClient is intended to be used by the default browser app only.

getBrowserClient

java-static fun getBrowserClient(context: Context!): SmsCodeBrowserClient!

Creates a new instance of SmsCodeBrowserClient for use in a Context. This SmsCodeBrowserClient is intended to be used by the default browser app only.