Xác minh qua SMS tự động bằng SMS Retriever API
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tính năng SMS Retriever API có thể tự động thực hiện quy trình xác minh người dùng dựa trên tin nhắn SMS trong ứng dụng Android mà không yêu cầu người dùng nhập mã xác minh theo cách thủ công mà không yêu cầu thêm bất kỳ quyền ứng dụng nào. Khi bạn
triển khai tính năng tự động xác minh qua SMS trong ứng dụng của mình, quy trình xác minh sẽ có dạng như sau:

- Người dùng bắt đầu quy trình xác minh qua SMS trong ứng dụng. Ứng dụng của bạn có thể nhắc người dùng cung cấp số điện thoại hoặc sử dụng bộ chọn gợi ý Smart Lock cho Mật khẩu nếu thông tin đó không cần phải tạo tài khoản người dùng.
- Ứng dụng gửi yêu cầu đến máy chủ của bạn để xác minh số điện thoại của người dùng.
Tuỳ thuộc vào thông tin có sẵn trong cơ sở dữ liệu người dùng của bạn, yêu cầu này
có thể bao gồm mã nhận dạng của người dùng, số điện thoại của người dùng hoặc cả hai.
- Đồng thời, ứng dụng của bạn gọi API Thu thập SMS để bắt đầu lắng nghe phản hồi qua SMS từ máy chủ của bạn.
- Máy chủ sẽ gửi một tin nhắn SMS đến người dùng, trong đó có mã dùng một lần để gửi lại cho máy chủ và băm dữ liệu nhận dạng ứng dụng.
- Khi thiết bị của người dùng nhận được tin nhắn SMS, Dịch vụ Google Play sẽ sử dụng hàm băm của ứng dụng để xác định rằng tin nhắn đó là dành cho ứng dụng của bạn và cung cấp văn bản tin nhắn cho ứng dụng thông qua SMS Retriever API.
- Ứng dụng sẽ phân tích cú pháp mã dùng một lần từ văn bản thông báo và gửi lại mã đó đến máy chủ của bạn.
- Máy chủ sẽ nhận mã một lần từ ứng dụng của bạn, xác minh mã và cuối cùng ghi lại rằng người dùng đã xác minh thành công tài khoản của họ.
Để triển khai tính năng tự động xác minh qua SMS trong ứng dụng, hãy xem hướng dẫn dành cho Android và máy chủ:
Hướng dẫn dành cho Android
Hướng dẫn dành cho máy chủ
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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)"]]