{% setvar book_path %}/android/reference/kotlin/_book.yaml{% endsetvar %} {% include "/android/_dackka-meta-tags.html" %}

SmsRetrieverClient

{% setvar page_path %}com/google/android/gms/auth/api/phone/SmsRetrieverClient.html{% endsetvar %} {% setvar doc_root_path %}/android/reference{% endsetvar %} {% setvar can_switch %}1{% endsetvar %} {% include "android/_kotlin_switcher2.md" %}

abstract class SmsRetrieverClient : GoogleApi, SmsRetrieverApi

kotlin.Any
   ↳ com.google.android.gms.common.api.GoogleApi
     ↳ com.google.android.gms.auth.api.phone.SmsRetrieverClient

The main entry point for interacting with SmsRetriever.

This does not require a GoogleApiClient. See GoogleApi for more information.

Summary

Public functions

abstract Task<Void!>!

Starts SmsRetriever, which waits for a matching SMS message until timeout (5 minutes).

abstract Task<Void!>!
startSmsUserConsent(senderAddress: String?)

Starts SmsUserConsent, which waits for an OTP-containing SMS message until timeout (5 minutes).

Inherited functions

From com.google.android.gms.common.api.GoogleApi
GoogleApiClient!
Api.Client!
buildApiClient(
    looper: Looper!,
    clientConnection: GoogleApiManager.ClientConnection<O!>!
)
ClientSettings.Builder!
SignInCoordinator!
createSignInCoordinator(context: Context!, handler: Handler!)
Task<Boolean!>!
T!
<A : Api.AnyClient?, T : BaseImplementation.ApiMethodImpl<Result!, A!>?> doBestEffortWrite(
    methodImpl: T!
)
Task<TResult!>!
<TResult, A : Api.AnyClient?> doBestEffortWrite(
    methodImpl: TaskApiCall<A!, TResult!>!
)
T!
<A : Api.AnyClient?, T : BaseImplementation.ApiMethodImpl<Result!, A!>?> doRead(
    methodImpl: T!
)
Task<TResult!>!
<TResult, A : Api.AnyClient?> doRead(methodImpl: TaskApiCall<A!, TResult!>!)
Task<Void!>!
<A : Api.AnyClient?, T : RegisterListenerMethod<A!, Any!>?, U : UnregisterListenerMethod<A!, Any!>?> doRegisterEventListener(
    registerMethod: T!,
    unregisterMethod: U!
)

This function is deprecated.

Task<Boolean!>!
T!
<A : Api.AnyClient?, T : BaseImplementation.ApiMethodImpl<Result!, A!>?> doWrite(
    methodImpl: T!
)
Task<TResult!>!
<TResult, A : Api.AnyClient?> doWrite(methodImpl: TaskApiCall<A!, TResult!>!)
Api<O!>!
String!
ApiKey<O!>!
O!
Context!
String!
String!

This function is deprecated.

Int
Looper!
ListenerHolder<L!>!
<L> registerListener(listener: L!, listenerType: String!)

Inherited properties

From com.google.android.gms.common.api.GoogleApi

Public functions

startSmsRetriever

abstract fun startSmsRetriever(): Task<Void!>!

Starts SmsRetriever, which waits for a matching SMS message until timeout (5 minutes). The matching SMS message will be sent via a Broadcast Intent with action SMS_RETRIEVED_ACTION. The Intent contains Extras with keys EXTRA_SMS_MESSAGE for the retrieved SMS message as a String, and EXTRA_STATUS for Status to indicate SUCCESS, DEVELOPER_ERROR, ERROR, or TIMEOUT.

Note: Add SEND_PERMISSION in registerReceiver while registering the receiver to detect that the broadcast intent is from the SMS Retriever. Be aware that this detection only works on devices using Google Play services v19.8.31 and later.

The possible causes for errors are:

Returns
Task<Void!>!

a Task for the call. Attach an OnCompleteListener and then check isSuccessful to determine if it was successful.

startSmsUserConsent

abstract fun startSmsUserConsent(senderAddress: String?): Task<Void!>!

Starts SmsUserConsent, which waits for an OTP-containing SMS message until timeout (5 minutes). OTP-containing SMS message can be retrieved with two steps.

Note: Add SEND_PERMISSION in registerReceiver while registering the receiver to detect that the broadcast intent is from the SMS Retriever. Be aware that this detection only works on devices using Google Play services v19.8.31 and later.

  1. [Get consent Intent] While OTP-containing SMS message comes, a consent Intent will be sent via a Broadcast Intent with action SMS_RETRIEVED_ACTION. The Intent contains Extras with keys EXTRA_CONSENT_INTENT for the consent Intent and EXTRA_STATUS for Status to indicate SUCCESS or TIMEOUT.
  2. [Get OTP-containing SMS message] Calls startActivityForResult with consent Intent to launch a consent dialog to get user's approval, then the OTP-containing SMS message can be retrieved from the activity result.
Parameters
senderAddress: String?

address of desired SMS sender, or null to retrieve any sender

Returns
Task<Void!>!

a Task for the call. Attach an OnCompleteListener and then check isSuccessful to determine if it was successful.