การยืนยัน SMS อัตโนมัติด้วย SMS Retriever API
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เมื่อใช้ SMS Fetchr API คุณจะดําเนินการยืนยันผู้ใช้ทาง SMS ในแอป Android ได้โดยอัตโนมัติ โดยที่ผู้ใช้ไม่จําเป็นต้องพิมพ์รหัสยืนยันเองและไม่จําเป็นต้องให้สิทธิ์แอปเพิ่ม เมื่อคุณใช้การยืนยันทาง SMS อัตโนมัติในแอป ขั้นตอนการยืนยันจะมีลักษณะดังนี้

- ผู้ใช้เริ่มการยืนยันทาง SMS ในแอป แอปอาจแจ้งให้ผู้ใช้ระบุหมายเลขโทรศัพท์ หรือใช้ตัวเลือกคําแนะนํา Smart Lock สําหรับรหัสผ่าน
หากข้อมูลนั้นไม่จําเป็นในการสร้างบัญชีของผู้ใช้
- แอปส่งคําขอไปยังเซิร์ฟเวอร์เพื่อยืนยันหมายเลขโทรศัพท์ของผู้ใช้
คําขอนี้อาจประกอบด้วยรหัสของผู้ใช้ หมายเลขโทรศัพท์ของผู้ใช้ หรือทั้ง 2 อย่าง ขึ้นอยู่กับข้อมูลที่มีอยู่ในฐานข้อมูลผู้ใช้
- ในขณะเดียวกัน แอปจะเรียก SMS Fetchr API เพื่อเริ่มฟังการตอบกลับทาง SMS จากเซิร์ฟเวอร์ของคุณ
- เซิร์ฟเวอร์ของคุณจะส่งข้อความ SMS ให้ผู้ใช้ที่มีรหัสแบบใช้ครั้งเดียวเพื่อส่งกลับไปยังเซิร์ฟเวอร์และแฮชที่ระบุแอปของคุณ
- เมื่ออุปกรณ์ได้รับข้อความ SMS บริการ Google Play จะใช้แฮชของแอปเพื่อระบุว่าข้อความนั้นๆ มีไว้สําหรับแอปของคุณหรือไม่ และทําให้ SMS พร้อมใช้งานสําหรับแอปของคุณผ่านทาง SMS Fetchr API
- แอปจะแยกวิเคราะห์รหัสแบบใช้ครั้งเดียวจากข้อความตัวอักษรและส่งกลับไปยังเซิร์ฟเวอร์ของคุณ
- เซิร์ฟเวอร์จะได้รับรหัสแบบใช้ครั้งเดียวจากแอป ยืนยันรหัส และบันทึกในที่สุดว่าผู้ใช้ได้ยืนยันบัญชีของตนเรียบร้อยแล้ว
หากต้องการใช้การยืนยัน 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)"]]