With the SMS Retriever API, you can perform SMS-based user verification in yourAndroid app automatically, without requiring the user to manually typeverification codes, and without requiring any extra app permissions. When youimplement automatic SMS verification in your app, the verification flow lookslike this:
- A user initiates SMS verification in your app. Your app might prompt theuser to provide a phone number or use theSmart Lock for Passwords hint selectorif that information wasn't required to create the user's account.
- Your app makes a request to your server to verify the user's phone number.Depending on what information is available in your user database, thisrequest might include the user's ID, the user's phone number, or both.
- At the same time, your app calls the SMS Retriever API to begin listeningfor an SMS response from your server.
- Your server sends an SMS message to the user that includes a one-time codeto be sent back to your server, and a hash that identifies your app.
- When the user's device receives the SMS message, Google Play services usesthe app hash to determine that the message is intended for your app, andmakes the message text available to your app through the SMS Retriever API.
- Your app parses out the one-time code from the message text and sends itback to your server.
- Your server receives the one-time code from your app, verifies the code, andfinally records that the user has successfully verified their account.
To implement automatic SMS verification in your app, see the Android and serverguides:
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-10-18 UTC.
[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }] [{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]