مهم : از 1 مه 2024 ، اپل برای برنامههای iOS که از SDKهای متداول استفاده میکنند، از جمله GoogleSignIn-iOS، به مانیفستهای حریم خصوصی و امضا نیاز دارد . قبل از 1 مه 2024 به GoogleSignIn-iOS نسخه 7.1.0+ ارتقا دهید. راهنمای ارتقاء ما را دنبال کنید.
شروع به استفاده از App Check for Google Sign-in در iOS کنید
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این صفحه به شما نشان می دهد که چگونه برنامه بررسی برنامه را در یک برنامه iOS فعال کنید. وقتی برنامه بررسی را فعال میکنید، مطمئن میشوید که فقط برنامه شما میتواند از طرف پروژه شما به نقاط پایانی Google OAuth 2.0 دسترسی داشته باشد. مروری بر این ویژگی را ببینید.
App Check از App Attest برای کمک به تأیید اینکه درخواستهای OAuth 2.0 از برنامه معتبر شما میآیند استفاده میکند. App Check از App Attest برای تجزیه و تحلیل خطر تقلب استفاده نمی کند.
App Check را می توان در آن فعال کردGoogle API Console یا در کنسول Firebase . لازم نیست آن را در هر دو مکان فعال کنید، فقط یکی کافی است.
Google API Console
برای فعال کردن موفقیت آمیز App Check برای سرویس گیرنده iOS خود، شرایط زیر باید رعایت شود:
باید یک شناسه تیم برای کلاینت iOS خود مشخص کنید.
شما نباید از علامت عام در شناسه بسته خود استفاده کنید زیرا می تواند به بیش از یک برنامه حل شود. این بدان معناست که ID بسته نباید دارای علامت ستاره (*) باشد.
برای فعال کردن «بررسی برنامه»، دکمه جابجایی «بررسی برنامه Firebase» را در نمای ویرایش کلاینت iOS خود، «محافظت از سرویس گیرنده OAuth از سوء استفاده» را روشن کنید.
پس از فعال کردن بررسی برنامه، معیارهای مربوط به درخواست های OAuth از مشتری خود را در نمای ویرایش مشتری OAuth مشاهده خواهید کرد. درخواستهای منابع تأیید نشده مسدود نمیشوند تا زمانی که بررسی برنامه را اجرا نکنید . اطلاعات موجود در صفحه نظارت بر معیارها می تواند به شما در تعیین زمان شروع اجرا کمک کند.
هنگام فعال کردن بررسی برنامه برای برنامه iOS خود، ممکن است خطاهای مربوط به ویژگی بررسی برنامه را مشاهده کنید. برای رفع این خطاها، موارد زیر را امتحان کنید:
بررسی کنید که شناسه بسته و شناسه تیمی که مشخص کردهاید معتبر هستند.
بررسی کنید که از علامت عام برای شناسه بسته استفاده نمیکنید.
کنسول Firebase
برای استفاده از App Check با Google Sign-in باید یک پروژه Firebase داشته باشید.
اگر برنامه شما قبلاً از Firebase استفاده می کند، از همان پروژه استفاده کنید.
اگر برنامه شما از Google Sign-in استفاده میکند، اما از Firebase استفاده نمیکند، شما از قبل یک پروژه Google Cloud دارید. هنگامی که یک پروژه جدید در کنسول Firebase ایجاد می کنید، Firebase را با انتخاب آن به پروژه Google Cloud خود اضافه کنید.
اگر قبلاً این کار را نکردهاید، برنامههای iOS خود را با استفاده از صفحه تنظیمات پروژه کنسول Firebase به پروژه Firebase خود اضافه کنید.
برنامه های خود را برای استفاده از App Check با ارائه دهنده App Attest در بخش App Check کنسول Firebase ثبت کنید.
مطمئن شوید که همه مشتریان OAuth پروژه شما به یک برنامه مرتبط هستند.
اگر کلاینتهای بدون پیوند دارید، پیامی را در بخش «شناسه Google برای iOS» در صفحه «بررسی برنامه» میبینید که میگوید: «شما n کلاینت OAuth بدون پیوند دارید که به تنظیمات بیشتری نیاز دارند».
بعلاوه، اگر برخی از سرویس گیرندگان OAuth را پس از تنظیم آن ها در بررسی برنامه حذف کرده باشید، پیامی را مشاهده خواهید کرد که می گوید: "شما n بازنویسی دارید بدون مشتری OAuth منطبق". میتوانید با حذف آن موارد لغو، با خیال راحت پاکسازی کنید.
میتوانید در صفحه مشتریان OAuth کنسول Firebase، کلاینتهای بدون پیوند را به یک برنامه موجود یا جدید پیوند دهید.
2. کتابخانه Google Sign-in را به برنامه خود اضافه کنید
در پروژه Xcode خود، وابستگی Google Sign-in را روی نسخه 8.0.0 یا بالاتر تنظیم کنید:
SPM
قانون وابستگی googlesignin-ios را روی نسخه 8.0.0 یا بالاتر تنظیم کنید.
CocoaPods
Podfile خود را به روز کنید:
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/firebase/SpecsDev.git'
target 'YourAppName' do
use_frameworks!
pod 'GoogleSignIn','~> 8.0'
:git => 'https://github.com/google/GoogleSignIn-iOS.git'
pod 'GoogleSignInSwiftSupport' # If you use SwiftUI.
end
سپس، pod install اجرا کنید و فایل .xcworkspace ایجاد شده را باز کنید.
در Xcode، قابلیت App Attest را به برنامه خود اضافه کنید.
در فایل .entitlements پروژه خود، محیط App Attest را روی production تنظیم کنید.
3. App Check را اولیه کنید
در روش didFinishLaunchingWithOptions نماینده برنامه شما، GIDSignIn.sharedInstance.configure(completion:) را فراخوانی کنید. شما باید این روش را هرچه زودتر در چرخه عمر برنامه خود فراخوانی کنید تا تأخیر درک شده توسط کاربر را به حداقل برسانید.
importSwiftUIimportGoogleSignInclassAppDelegate:NSObject,UIApplicationDelegate{funcapplication(_application:UIApplication,didFinishLaunchingWithOptionslaunchOptions:[UIApplication.LaunchOptionsKey:Any]?=nil)->Bool{#iftargetEnvironment(simulator)// Configure for debugging.// See: https://developers.google.com/identity/sign-in/ios/appcheck/debug-provider#elseGIDSignIn.sharedInstance.configure{errorinifleterror{print("Error configuring `GIDSignIn` for Firebase App Check: \(error)")}}#endifreturntrue}}@mainstructYourAppNameApp:App{@UIApplicationDelegateAdaptor(AppDelegate.self)varappDelegate// ...}
مراحل بعدی
هنگامی که کتابخانه App Check در برنامه شما نصب شد، شروع به توزیع برنامه به روز شده بین کاربران خود کنید.
برنامه مشتری بهروزرسانی شده شروع به ارسال نشانههای App Check به همراه هر درخواستی میکند که به نقاط پایانی احراز هویت Google ارسال میکند، اما نقطههای پایانی نیازی به معتبر بودن نشانهها ندارند تا زمانی که اجرای را در بخش بررسی برنامه کنسول Firebase فعال نکنید.
معیارها را پایش کنید
با این حال، قبل از فعال کردن اعمال، باید مطمئن شوید که انجام این کار باعث اختلال در کاربران قانونی فعلی شما نمی شود. از سوی دیگر، اگر استفاده مشکوک از منابع برنامه خود را مشاهده کردید، ممکن است بخواهید زودتر اجرای آن را فعال کنید.
وقتی متوجه شدید که بررسی برنامه چگونه بر کاربران شما تأثیر می گذارد و آماده ادامه کار هستید، می توانید اجرای بررسی برنامه را فعال کنید .
از App Check در محیط های اشکال زدایی استفاده کنید
اگر بعد از اینکه برنامه خود را برای بررسی برنامه ثبت کردید، می خواهید برنامه خود را در محیطی اجرا کنید که App Check معمولاً آن را به عنوان معتبر طبقه بندی نمی کند، مانند شبیه ساز در طول توسعه، یا از یک محیط یکپارچه سازی پیوسته (CI)، می توانید یک ساختار اشکال زدایی از برنامه خود ایجاد کنید که به جای App Attest از ارائه دهنده اشکال زدایی App Check استفاده می کند.
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThis guide explains how to enable App Check for your iOS app to enhance security by ensuring only your app can access Google's OAuth 2.0 endpoints.\u003c/p\u003e\n"],["\u003cp\u003eApp Check utilizes App Attest to verify the authenticity of OAuth 2.0 requests originating from your app, but it doesn't use it for fraud risk analysis.\u003c/p\u003e\n"],["\u003cp\u003eBefore enabling App Check, you need to integrate Google Sign-in, set up your project in either the Google API Console or Firebase Console, and add the necessary libraries and capabilities to your Xcode project.\u003c/p\u003e\n"],["\u003cp\u003eOnce implemented, monitor App Check metrics to understand its impact on users before enabling enforcement to block unverified requests.\u003c/p\u003e\n"],["\u003cp\u003eFor debugging and testing in environments like simulators, utilize the App Check debug provider as an alternative to App Attest.\u003c/p\u003e\n"]]],[],null,["This page shows you how to enable App Check in an iOS app. When you enable App\nCheck, you help ensure that only your app can access Google's OAuth 2.0\nendpoints on behalf of your project. See an [Overview](/identity/sign-in/ios/appcheck) of this feature.\n\nApp Check uses [App Attest](https://developer.apple.com/documentation/devicecheck/establishing_your_app_s_integrity) to help verify that OAuth 2.0\nrequests are coming from your authentic app.\nApp Check does not use App Attest to [analyze fraud risk](https://developer.apple.com/documentation/devicecheck/assessing_fraud_risk).\n\nBefore you begin\n\n1. Make sure you have Xcode 12.5 or newer.\n\n2. Integrate Google Sign-in into your iOS app, using the\n [Google Sign-in library](/identity/sign-in/ios/start-integrating).\n\n1. Set up your project\n\nApp Check can be enabled in the [Google API Console](#api-console-setup)\nor in the [Firebase Console](#firebase-console-setup). It is not necessary to enable it in both\nplaces, just one is sufficient.\n\nGoogle API Console The following requirements must be met to successfully enable App Check for your iOS client:\n\n- You must specify a team ID for your iOS client.\n- You must not use a wildcard in your bundle ID since it can resolve to more than one app. This means that the bundle ID must not include the asterisk (\\*) symbol.\n\n| **Warning:** When App Check is enabled, you won't be able to edit your OAuth client bundle ID without creating a new client. Before creating your iOS client or enabling App Check, verify that you are using the correct bundle ID. Updating your bundle ID for an existing project can result in a broken experience for users of your apps if you are using the bundle ID as a redirect URI.\nTo enable App Check, turn on the **Protect your OAuth client from abuse with Firebase App Check** toggle button in the edit view of your iOS client.\n\n\nAfter enabling App Check, you will start seeing metrics related to OAuth requests from your\nclient in the edit view of the OAuth client. Requests from unverified sources won't be blocked\nuntil you [enforce App Check](#enforce-app-check). The information in the\nmetrics monitoring page can help you determine when to start enforcement.\n\n\nYou might see errors related to the App Check feature when enabling App Check for your iOS app. To\nfix these errors, try the following:\n\n- Verify that the bundle ID and team ID you specified are valid.\n- Verify that you are not using a wildcard for the bundle ID.\n\nFirebase Console\n\n1. You must have a Firebase project to use App Check with\n Google Sign-in.\n\n - If your app already uses Firebase, use the same project.\n\n - If your app uses Google Sign-in, but not Firebase, you already have a\n Google Cloud project. Add Firebase to your Google Cloud project by\n selecting it when you create a new project in the\n [Firebase console](https://console.firebase.google.com/)\n\n See also:\n [Relationship between Firebase projects and Google Cloud](https://firebase.google.com/docs/projects/learn-more#firebase-cloud-relationship)\n2. If you haven't already done so, add your iOS apps to your Firebase project\n using the [Project settings](https://console.firebase.google.com/project/_/settings/general/) page of the Firebase console.\n\n3. Register your apps to use App Check with the App Attest provider in the\n [App Check](https://console.firebase.google.com/project/_/appcheck/apps) section of the Firebase console.\n\n | **Note:** The **Token time to live** setting has no effect on the App Check tokens used with Google Sign-in. A fresh App Attest assertion is obtained prior to each interaction with Google's OAuth 2.0 endpoints.\n4. Make sure all of your project's OAuth clients are linked to an app.\n\n If you have unlinked clients, you'll see a message in the **Google Identity\n for iOS** section of the [App Check](https://console.firebase.google.com/project/_/appcheck/apps) page that says, \"You have\n \u003cvar translate=\"no\"\u003en\u003c/var\u003e unlinked OAuth clients which require additional setup.\"\n\n Additionally, if you have deleted some OAuth clients after setting them up\n in App Check, you'll see a message that says, \"You have \u003cvar translate=\"no\"\u003en\u003c/var\u003e\n overrides with no matching OAuth client\". You can safely clean up by\n deleting those overrides.\n\n You can link unlinked clients to an existing or new app on the\n [OAuth clients](https://console.firebase.google.com/project/_/appcheck/products/oauth) page of the Firebase console.\n\n2. Add the Google Sign-in library to your app\n\n1. In your Xcode project, set the Google Sign-in dependency to version\n `8.0.0` or higher :\n\n SPM\n\n Set the dependency rule of `googlesignin-ios` to version `8.0.0` or\n higher.\n\n CocoaPods\n\n Update your `Podfile`: \n\n source 'https://github.com/CocoaPods/Specs.git'\n source 'https://github.com/firebase/SpecsDev.git'\n\n target 'YourAppName' do\n use_frameworks!\n\n pod 'GoogleSignIn','~\u003e 8.0'\n :git =\u003e 'https://github.com/google/GoogleSignIn-iOS.git'\n pod 'GoogleSignInSwiftSupport' # If you use SwiftUI.\n end\n\n Then, run `pod install` and open the created `.xcworkspace` file.\n2. In Xcode, add the **App Attest** capability to your app.\n\n3. In your project's `.entitlements` file, set the App Attest environment to\n `production`.\n\n | **Note:** App Check doesn't accept tokens generated in the App Attest sandbox environment.\n\n3. Initialize App Check\n\nIn your app delegate's `didFinishLaunchingWithOptions` method, call\n`GIDSignIn.sharedInstance.configure(completion:)`. You should call this method\nas early as possible in your app's lifecycle to minimize user-perceived latency.\n**Note:** Calling `GIDSignIn.sharedInstance.configure(completion:)` configures App Check for use in production. When building your app for testing and debugging, call `GIDSignIn.sharedInstance.configureDebugProvider(withAPIKey:completion:)`. See [Use App Check with the debug provider](/identity/sign-in/ios/appcheck/debug-provider). \n\n import SwiftUI\n import GoogleSignIn\n\n class AppDelegate: NSObject, UIApplicationDelegate {\n func application(\n _ application: UIApplication,\n didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil\n ) -\u003e Bool {\n #if targetEnvironment(simulator)\n // Configure for debugging.\n // See: https://developers.google.com/identity/sign-in/ios/appcheck/debug-provider\n #else\n GIDSignIn.sharedInstance.configure { error in\n if let error {\n print(\"Error configuring `GIDSignIn` for Firebase App Check: \\(error)\")\n }\n }\n #endif\n\n return true\n }\n }\n\n @main\n struct YourAppNameApp: App {\n @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate\n\n // ...\n }\n\nNext steps\n\nOnce the App Check library is installed in your app, start distributing the\nupdated app to your users.\n| **Note:** If you are adding App Attest to a production app with a large active user base, Apple recommends [gradually onboarding users](https://developer.apple.com/documentation/devicecheck/preparing_to_use_the_app_attest_service#3578850) to avoid encountering quota limits.\n\nThe updated client app will begin sending App Check tokens along with every\nrequest it makes to Google's authentication endpoints, but the endpoints won't\nrequire the tokens to be valid until you enable enforcement in the App Check\nsection of the Firebase console.\n\nMonitor metrics\n\nBefore you enable enforcement, however, you should make sure that doing so won't\ndisrupt your existing legitimate users. On the other hand, if you're seeing\nsuspicious use of your app resources, you might want to enable enforcement\nsooner.\n\nTo help make this decision, you can look at\n[App Check metrics for Google Sign-in](/identity/sign-in/ios/appcheck/monitor-metrics).\n\nEnable App Check enforcement\n\nWhen you understand how App Check will affect your users and you're ready to\nproceed, you can [enable App Check enforcement](/identity/sign-in/ios/appcheck/enable-enforcement).\n\nUse App Check in debug environments\n\nIf, after you have registered your app for App Check, you want to run your app\nin an environment that App Check would normally not classify as valid, such as a\nsimulator during development, or from a continuous integration (CI) environment,\nyou can create a debug build of your app that uses the App Check debug provider\ninstead of App Attest.\n\nSee [Use App Check with the debug provider](/identity/sign-in/ios/appcheck/debug-provider)."]]