透過 SMS Retriever API 自動進行簡訊驗證
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
使用 SMS Retriever API 即可在 Android 應用程式中自動執行簡訊使用者驗證,不必請使用者手動輸入驗證碼,也不需要任何額外的應用程式權限。在應用程式中實作自動簡訊驗證時,驗證流程應如下所示:

- 使用者在應用程式中啟動簡訊驗證。如果應用程式在建立使用者帳戶時不需要這些資訊,可能會提示使用者提供電話號碼,或是使用密碼專用 Smart Lock 提示選取器。
- 應用程式會向伺服器發出要求,以驗證使用者的電話號碼。視使用者資料庫中提供的資訊而定,這項要求可能包含使用者的 ID 和/或電話號碼。
- 同時,應用程式會呼叫 SMS Retriever API,開始監聽伺服器傳來的簡訊回應。
- 您的伺服器會傳送一則簡訊給使用者,其中包含要傳送到伺服器的一次性代碼,以及可識別應用程式的雜湊。
- 當使用者的裝置收到簡訊時,Google Play 服務會使用應用程式雜湊來判斷訊息適用於您的應用程式,並透過 SMS Retriever API 讓應用程式使用訊息文字。
- 應用程式會剖析訊息文字中的一次性代碼,並傳回您的伺服器。
- 您的伺服器會從應用程式收到一次性代碼並驗證代碼,最後再確認使用者已成功驗證帳戶。
如要在應用程式中實作自動簡訊驗證功能,請參閱 Android 和伺服器指南:
Android 指南
伺服器指南
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-11-04 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"缺少我需要的資訊"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"過於複雜/步驟過多"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"過時"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻譯問題"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"示例/程式碼問題"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"容易理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"確實解決了我的問題"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]