Verificação automática de SMS com a API SMS Retriever
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Com a API SMS Retriever, é possível fazer a verificação automática de usuários com base em SMS no
app Android automaticamente, sem que os usuários precisem digitar manualmente
os códigos de verificação e sem necessidade de permissões do app adicionais. Quando você implementa a verificação automática de SMS no seu app, o fluxo de verificação é semelhante a este:
Um usuário inicia a verificação por SMS no app. Seu app pode solicitar que
o usuário forneça um número de telefone ou use o
seletor de dica do Smart Lock para senhas,
caso essas informações não sejam necessárias para criar a conta.
O app faz uma solicitação ao servidor para verificar o número de telefone do usuário.
Dependendo das informações disponíveis no seu banco de dados de usuários, essa
solicitação pode incluir o ID do usuário, o número de telefone do usuário ou ambos.
Ao mesmo tempo, o app chama a API SMS Retriever para começar
a ouvir uma resposta por SMS do servidor.
O servidor envia uma mensagem SMS para o usuário, incluindo um código único que será enviado de volta ao seu servidor, e um hash que identifica seu aplicativo.
Quando o dispositivo do usuário recebe a mensagem SMS, o Google Play Services usa
o hash do app para determinar se a mensagem é destinada ao app e
disponibiliza o texto da mensagem para o app usando a API SMS Retriever.
O app analisa o código único do texto da mensagem e o envia
de volta ao servidor.
O servidor recebe o código único do app, verifica o código e
registra por fim a conclusão da verificação.
Para implementar a verificação automática de SMS no seu app, consulte os guias do Android e do servidor:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-07-25 UTC."],[[["\u003cp\u003eThe SMS Retriever API enables automatic SMS verification in Android apps, eliminating manual code entry for users.\u003c/p\u003e\n"],["\u003cp\u003eThis API streamlines user verification by having your app listen for an SMS message containing a one-time code, sent by your server after a verification request.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Play services identifies the incoming SMS message as intended for your app using an app hash included in the message, ensuring secure delivery of the verification code.\u003c/p\u003e\n"],["\u003cp\u003eThe SMS Retriever API enhances user experience and security by automating verification without requiring extra app permissions.\u003c/p\u003e\n"]]],[],null,["# Automatic SMS Verification with the SMS Retriever API\n\nWith the SMS Retriever API, you can perform SMS-based user verification in your\nAndroid app automatically, without requiring the user to manually type\nverification codes, and without requiring any extra app permissions. When you\nimplement automatic SMS verification in your app, the verification flow looks\nlike this:\n\n[](/static/identity/sms-retriever/flow-overview.png)\n\n1. A user initiates SMS verification in your app. Your app might prompt the user to provide a phone number or use the [Smart Lock for Passwords hint selector](/identity/smartlock-passwords/android/retrieve-hints) if that information wasn't required to create the user's account.\n2. 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, this request might include the user's ID, the user's phone number, or both.\n3. At the same time, your app calls the SMS Retriever API to begin listening for an SMS response from your server.\n4. Your server sends an SMS message to the user that includes a one-time code to be sent back to your server, and a hash that identifies your app.\n5. When the user's device receives the SMS message, Google Play services uses the app hash to determine that the message is intended for your app, and makes the message text available to your app through the SMS Retriever API.\n6. Your app parses out the one-time code from the message text and sends it back to your server.\n7. Your server receives the one-time code from your app, verifies the code, and finally records that the user has successfully verified their account.\n\nTo implement automatic SMS verification in your app, see the Android and server\nguides:\n\n[Android Guide](/identity/sms-retriever/request)\n[Server Guide](/identity/sms-retriever/verify)"]]