Send SMS using Twilio in android application

Save

So many times we need to send the SMS or OTP(One time password ) to the user mobile number through our application it can be for any purpose like verification your account , message etc and Twilio make this task more easy for us. Today i am going to share the code for  send sms using twilio.

Twilio is a cloud communications platforms it makes sending and receiving SMS easy, it works as an SMS provider which will send a password to users that attempt to login with a properly configured security policy. You can integrate Twilio SMS service in your application for sending OTP SMS to authenticate the users.

For this process first  thing we need to do is Sign up for a twilio account and we will get –

1. Twillio Account SID
2. Auth token
3. Twilio phone number

Now for the reference i have  added some code with retrofit-

Add the  retrofit dependency  in build.greadle file

we will create a interface for twilio api .

In the above code  ACCOUNT_SID is Twillio Account SID and Authorization is basic Authentication which is base64 of account sid and auth token.

To send sms i have passed the url with base authentication here is the code

In the above code the smsData contain these perameters-

From – the number from you want to send sms.
To –  the number to which you want to send sms
Body – Message you want to send.

If your twilio account is trial account you have to add the test mobile number to the twillio account.

REFERENCE

you can also refer  their integration guide –

https://www.twilio.com/docs/sms

Hope it will help you Thanks for reading.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


1 comments

  • Ayetolu Samuel
    Thanks for the tutorial,
    Please am getting BAD REQUEST…
    How can i rectify this…
  • css.php

    We've bought a Shopware Extension which is a hybrid App, which we can now offer in the Google Play Store and the IOS App Store. I'am still impressed how fast and how sharp the support team leads us through every process of the App-Store clarification. Very fast and useful response.

    Markus Walter

    Markus Walter

    Founder, Das Apartment Living

    Talk to Sales

    Global

    Live Chat
    Start a Project


      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home