Rate this page:

Twilio Verification SDK for Android - SDK Reference

For a quick start and a step-by-step guide, please refer to Twilio Verification SDK for Android - Integration Guides

Technical information

Downloadable via jCenter. 
Weight: 26KB (v1.0.0)
Method count: 218 methods.

Dependencies: retrofit2, gson, okhttp3.

To initialize a phone verification process you can call

TwilioVerification instance

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

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.

public static VerificationStatus getVerificationStatus(Intent verificationIntent);

VerificationStatus object: a response holder that contains three methods:

public State getState();

Returns an 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()
public String getVerificationToken();

The verification token will have the following structure

    valid: <true|false>,
    iat: <timestamp>,
    exp: <timestamp>,
    verification: {
        uuid: <PV-uuid>,
        via: <sms|call>,
        phone_number:  <phonenumber>,
        code_length: <4-10>

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.

public VerificationException getVerificationException();

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

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

Loading Code Sample...

        Thank you for your feedback!

        Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!