تأیید خودکار پیامک با API SMS Retriever
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
با SMS Retriever API، میتوانید بدون نیاز به تایپ دستی کدهای تأیید توسط کاربر، و بدون نیاز به مجوزهای اضافی برنامه، تأیید کاربر مبتنی بر پیامک را در برنامه Android خود به طور خودکار انجام دهید. هنگامی که تأیید خودکار پیامک را در برنامه خود پیاده سازی می کنید، جریان تأیید به صورت زیر است:

- کاربر تأیید پیامک را در برنامه شما آغاز می کند. اگر این اطلاعات برای ایجاد حساب کاربر لازم نبود، ممکن است برنامه شما از کاربر بخواهد شماره تلفنی ارائه دهد یا از انتخابگر راهنمایی Smart Lock for Passwords استفاده کند.
- برنامه شما از سرور شما درخواست می کند تا شماره تلفن کاربر را تأیید کند. بسته به اینکه چه اطلاعاتی در پایگاه داده کاربر شما موجود است، این درخواست ممکن است شامل شناسه کاربر، شماره تلفن کاربر یا هر دو باشد.
- در همان زمان، برنامه شما با SMS Retriever API تماس می گیرد تا شروع به گوش دادن به پاسخ SMS از سرور شما کند.
- سرور شما یک پیام کوتاه برای کاربر ارسال می کند که شامل یک کد یکبار مصرف برای بازگرداندن به سرور شما و یک هش است که برنامه شما را شناسایی می کند.
- هنگامی که دستگاه کاربر پیام اس ام اس را دریافت می کند، سرویس های Google Play از هش برنامه برای تعیین اینکه پیام برای برنامه شما در نظر گرفته شده است استفاده می کند و متن پیام را از طریق SMS Retriever API در دسترس برنامه شما قرار می دهد.
- برنامه شما کد یکبار مصرف را از متن پیام تجزیه می کند و آن را به سرور شما می فرستد.
- سرور شما کد یکبار مصرف را از برنامه شما دریافت می کند، کد را تأیید می کند و در نهایت ثبت می کند که کاربر با موفقیت حساب خود را تأیید کرده است.
برای اجرای تأیید خودکار پیامک در برنامه خود، به راهنمای Android و سرور مراجعه کنید:
راهنمای اندروید راهنمای سرور
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی."],[[["\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)"]]