implementsSmsRetrieverApi
The main entry point for interacting with SmsRetriever.
This does not require aGoogleApiClient
.
SeeGoogleApi
for more information.
Public Method Summary
abstractTask<Void> |
startSmsRetriever()
Starts
SmsRetriever ,which waits for a matching SMS message until
timeout (5 minutes).
|
abstractTask<Void> |
startSmsUserConsent(String
senderAddress)
Starts
SmsUserConsent ,which waits for an OTP-containing SMS
message until timeout (5 minutes).
|
Inherited Method Summary
Public Methods
public abstractTask<Void>startSmsRetriever()
StartsSmsRetriever
,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 aString
,
and
EXTRA_STATUS
forStatus
to
indicate SUCCESS, DEVELOPER_ERROR, ERROR, or TIMEOUT.
Note:Add
SEND_PERMISSION
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:
- DEVELOPER_ERROR: the caller app has incorrect number of certificates. Only one certificate is allowed.
- ERROR: the AppCode collides with other installed apps.
Returns
- a
Task
for the call. Attach anOnCompleteListener
and then checkisSuccessful()
to determine if it was successful.
public abstractTask<Void>startSmsUserConsent(String senderAddress)
StartsSmsUserConsent
,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
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.
- [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 keysEXTRA_CONSENT_INTENT
for the consent Intent andEXTRA_STATUS
forStatus
to indicate SUCCESS or TIMEOUT. - [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 | address of desired SMS sender, ornull to retrieve any sender |
---|
Returns
- a
Task
for the call. Attach anOnCompleteListener
and then checkisSuccessful()
to determine if it was successful.