Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Twilio Verification SDK for Android - SDK Reference


For a quick start and a step-by-step guide, refer to the Twilio Verification SDK for Android integration guides.


Technical information

technical-information page anchor

The Twilio Verification SDK for Android is downloadable via jCenter and has the following technical characteristics:

SDK package details

sdk-package-details page anchor
1
Downloadable via jCenter.
2
Weight: 26KB (v1.0.0)
3
Method count: 218 methods.
4
5
Dependencies: retrofit2, gson, okhttp3.

TwilioVerification instance

twilioverification-instance page anchor

To initialize a phone verification process, call startVerification():

startVerification method signature

startverification-method-signature page anchor
public void startVerification(String jwtToken, Via via);

If you decide to use the Via.SMS, then the SDK will automatically inspect the SMS inbox in the device and continue the process without interrupting the user.

Otherwise, as a fallback you can use Via.CALL This method will trigger a telephone call from Twilio and deliver a code to the user by voice. The language will be inferred by the API unless locale parameter was used in the JWT payload.

The user will need to manually input that code into your app and then your app will need to call checkVerificationPin() to complete the process

checkVerificationPin method signature

checkverificationpin-method-signature page anchor
public void checkVerificationPin(String pin);

When the BroadcastReceiver receives an intent, the verification status can be extracted with getVerificationStatus. The result will be a VerificationStatus object.

getVerificationStatus method signature

getverificationstatus-method-signature page anchor
public static VerificationStatus getVerificationStatus(Intent verificationIntent);

The VerificationStatus object is a response holder that contains three methods:

getState method signature

getstate-method-signature page anchor
public State getState();

Returns a State enum that can take as value: [ STARTED | AWAITING_VERIFICATION | SUCCESS | ERROR ]

  • STARTED: The start verification was called, but the SMS has not arrived yet.
  • AWAITING_VERIFICATION: The SMS arrived and we're waiting for the check call
  • SUCCESS: The pin was verified. The verification token is available in the VerificationStatus object through the getVerificationToken() method.
  • ERROR: There was an error while verifying. The exception can be recovered through the getVerificationException()

getVerificationToken method signature

getverificationtoken-method-signature page anchor
public String getVerificationToken();

The verification token has the following structure:

Verification token structure

verification-token-structure page anchor
1
{
2
valid: <true|false>,
3
iat: <timestamp>,
4
exp: <timestamp>,
5
verification: {
6
uuid: <PV-uuid>,
7
via: <sms|call>,
8
phone_number: <phonenumber>,
9
code_length: <4-10>
10
}
11
}

Returns the verification token, which is proof that the verification was successful. The backend can decrypt this token later with the AUTHY_API_KEY to verify this.

getVerificationException method signature

getverificationexception-method-signature page anchor
public VerificationException getVerificationException();

This property will hold the verification exception if it did not succeed.