Better Programming

Advice for programmers.

Follow publication

Member-only story

Android Automatic SMS Verification With Google’s SMS Retriever API

Satya Pavan Kantamani
Better Programming
Published in
4 min readApr 26, 2020

--

Image source: Automatic SMS Verification with the SMS Retriever API

In Android apps, it’s become a common procedure to use a mobile number as a user handle to verify the users. For this, technically speaking, we ask users for their mobile number and then hit an API with that number from the server. An SMS gets triggered and is received on the user mobile. The user enters this SMS code in the box provided to access the content of the app. Here there is a little bit overhead in the user experience.

This would be better if we automatically read the SMS code and verified the user in the background while in the foreground, the user is getting onboarded. If we can’t do the verification in the background, we can ask the user to enter it manually once the user is onboarded and before moving to the dashboard or home screen. This would ease the process and help the user to get onboarded easily. This would be a good feature that would differentiate your app from other apps that force users to enter it manually.

Introduction to SMS Retiever API

Google has introduced an SMS Retriever API with which we can perform SMS-based user verification in our Android app automatically, without requiring the user to manually type verification codes, and without requiring any extra app permissions. Using this API for verification wouldn’t bother users with whether they have entered the correct code or not. SMS Retriever API provides a fully automated user experience and should be used when possible.

If you don’t have control over the contents of the message — for example, if your app works with a financial institution that might want to verify the user’s phone number before approving a payment transaction inside your app — then you can use the SMS User Consent API.

Note: The SMS Retriever API is available only on Android devices with Play services version 10.2 and newer.

Implementation of SMS Retriever API

To automatically verify phone numbers, you must implement both the client and server portions of the verification flow. There are a few steps that need to be followed…

--

--

Satya Pavan Kantamani
Satya Pavan Kantamani

Written by Satya Pavan Kantamani

Android Dev, Interested in Traveling, App development. Based in Hyderabad, India. Catch me at https://about.me/satyapavankumar

Responses (1)

Write a response