SMS Retriever API を使用した SMS の自動確認
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
SMS Retriever API を使用すると、ユーザーが手動で確認コードを入力しなくても、Android アプリ内で SMS ベースのユーザー確認を自動的に実行できます。アプリの権限の追加も必要ありません。アプリに自動 SMS 検証を実装すると、検証フローは次のようになります。

- ユーザーがアプリで SMS による確認を開始します。アプリは、電話番号の入力を求めるプロンプトを表示するか、Smart Lock for Passwords ヒントセレクタを使用して、ユーザー アカウントの作成にその情報が必要ない場合は、プロンプトを表示します。
- アプリは、ユーザーに電話番号を確認するようリクエストします。
ユーザー データベースで使用可能な情報に応じて、このリクエストにはユーザー ID、ユーザーの電話番号、またはその両方が含まれる場合があります。
- 同時に、アプリは SMS Retriever API を呼び出して、サーバーからの SMS レスポンスのリッスンを開始します。
- サーバーはユーザーに SMS メッセージを送信します。このメッセージには、サーバーに送信される 1 回限りのコードと、アプリを識別するハッシュが含まれています。
- ユーザーのデバイスが SMS メッセージを受信すると、Google Play 開発者サービスは、アプリのハッシュを使用してメッセージがアプリ向けかどうかを判断し、そのメッセージを SMS Retriever API を通じてアプリで利用できるようにします。
- アプリはメッセージ テキストのワンタイム コードを解析し、それをサーバーに送り返します。
- サーバーがアプリから 1 回限りのコードを受け取り、コードを検証し、ユーザーがアカウントの確認に成功したことを最終的に記録します。
自動 SMS 検証をアプリに実装する方法については、Android のガイドとサーバーガイドをご覧ください。
Android ガイド
サーバーガイド
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-25 UTC。
[null,null,["最終更新日 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)"]]