0
votes

I used Twilio to send SMS verification in my app. I just send a single SMS per user using the Twilio REST API.

However, after launching, we got several complaints from international users. They never got the SMS.

What is the best way to implement SMS/Voice verification that works almost everywhere?

And yes, International SMS is enabled in my Twilio Account.

def sendByTwilio(phone, verificationCode):
try:
    account_sid = "XXXXX"
    auth_token = "XXXXXX"
    client = TwilioRestClient(account_sid, auth_token)
    rv = client.sms.messages.create(to="phone",
                                    from_="XXXXXXXXXX",
                                    body="Your verification code is "+str(verificationCode))
    return True
except TwilioRestException, e:
    pass

return False
3
I would NOT recommend Twilio. There docs say they support international SMS, but after talking to their tech reps it appears it does in fact, NOT work. Such a waste of time.GN.

3 Answers

2
votes

Twilio developer evangelist here.

Kamran is right, you should check your international permissions in your account.

One other thing is that you are using the SMS/Messages resource which has been deprecated. If you update your code to:

rv = client.messages.create(to="phone",
                            from_="XXXXXXXXXX",
                            body="Your verification code is "+str(verificationCode))

then you will use the newer Messages resource.

1
votes

Have you enabled the geographical location? If no you have to enabled it from twilio account settings. Secondary you should do some logging for TwilioException .May be number might not be prefixed with + sign which causes problems

1
votes

There are a couple of reasons why the SMS might not be working in international locations. Twilio works good on some places but not everywhere. In India they are very limited and would not recommend using them - https://www.twilio.com/help/faq/sms/are-there-limitations-on-sending-sms-messages-to-indian-mobile-devices.

I don't think that the API version would change the deliverability of the SMS, when you go international the hurdles of making sure the SMS is received goes beyond the SMS Gateway. Read this for more info on improving SMS reception globally check out this.