SmsRetriever

Kotlin|Java

public final classSmsRetriever


SmsRetriever provides access to Google services that help you retrieve SMS messages sent to your app without having to ask forandroid.permission.READ_SMS orandroid.permission.RECEIVE_SMS.

To useSmsRetriever, obtain an instance ofSmsRetrieverClient usinggetClient orgetClient, then start the SMS retriever service by callingstartSmsRetriever orstartSmsUserConsent. The service waits for a matching SMS message until timeout (5 minutes).

Summary

Constants

static finalString
EXTRA_CONSENT_INTENT = "com.google.android.gms.auth.api.phone.EXTRA_CONSENT_INTENT"

Intent extra key of the consent intent to be launched from client app.

static finalString
EXTRA_SIM_SUBSCRIPTION_ID = "com.google.android.gms.auth.api.phone.EXTRA_SIM_SUBSCRIPTION_ID"

[Optional] Intent extra key of the retrieved Sim card subscription Id if any, as anint.

static finalString
EXTRA_SMS_MESSAGE = "com.google.android.gms.auth.api.phone.EXTRA_SMS_MESSAGE"

Intent extra key of the retrieved SMS message as aString.

static finalString
EXTRA_SMS_ORIGINATING_ADDRESS = "com.google.android.gms.auth.api.phone.EXTRA_SMS_ORIGINATING_ADDRESS"

Intent extra key of the SMS originating address as aString.

static finalString
EXTRA_STATUS = "com.google.android.gms.auth.api.phone.EXTRA_STATUS"

Intent extra key ofStatus, which indicates SUCCESS or TIMEOUT.

static finalString
SEND_PERMISSION = "com.google.android.gms.auth.api.phone.permission.SEND"

Permission that's used to register the receiver to detect that the broadcaster is the SMS Retriever.

static finalString
SMS_RETRIEVED_ACTION = "com.google.android.gms.auth.api.phone.SMS_RETRIEVED"

Intent action when SMS message is retrieved.

Public methods

staticSmsRetrieverClient
getClient(Activity activity)

Create a new instance ofSmsRetrieverClient for use in anActivity.

staticSmsRetrieverClient
getClient(Context context)

Create a new instance ofSmsRetrieverClient for use in aContext.

Constants

EXTRA_CONSENT_INTENT

public static final String EXTRA_CONSENT_INTENT = "com.google.android.gms.auth.api.phone.EXTRA_CONSENT_INTENT"

Intent extra key of the consent intent to be launched from client app.

EXTRA_SIM_SUBSCRIPTION_ID

public static final String EXTRA_SIM_SUBSCRIPTION_ID = "com.google.android.gms.auth.api.phone.EXTRA_SIM_SUBSCRIPTION_ID"

[Optional] Intent extra key of the retrieved Sim card subscription Id if any, as anint.

EXTRA_SMS_MESSAGE

public static final String EXTRA_SMS_MESSAGE = "com.google.android.gms.auth.api.phone.EXTRA_SMS_MESSAGE"

Intent extra key of the retrieved SMS message as aString.

EXTRA_SMS_ORIGINATING_ADDRESS

public static final String EXTRA_SMS_ORIGINATING_ADDRESS = "com.google.android.gms.auth.api.phone.EXTRA_SMS_ORIGINATING_ADDRESS"

Intent extra key of the SMS originating address as aString.

EXTRA_STATUS

public static final String EXTRA_STATUS = "com.google.android.gms.auth.api.phone.EXTRA_STATUS"

Intent extra key ofStatus, which indicates SUCCESS or TIMEOUT.

SEND_PERMISSION

public static final String SEND_PERMISSION = "com.google.android.gms.auth.api.phone.permission.SEND"

Permission that's used to register the receiver to detect that the broadcaster is the SMS Retriever.

SMS_RETRIEVED_ACTION

public static final String SMS_RETRIEVED_ACTION = "com.google.android.gms.auth.api.phone.SMS_RETRIEVED"

Intent action when SMS message is retrieved.

Public methods

getClient

public static SmsRetrieverClient getClient(Activity activity)

Create a new instance ofSmsRetrieverClient for use in anActivity.

getClient

public static SmsRetrieverClient getClient(Context context)

Create a new instance ofSmsRetrieverClient for use in aContext.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-03-26 UTC.