שימוש ב-App Check עם ספק ניפוי הבאגים בפלטפורמות של Apple
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
אם אחרי שרשמתם את האפליקציה שלכם ל-App Check, אתם רוצים להריץ את האפליקציה בסביבה שApp Check בדרך כלל לא מסווגת כתקפה, כמו סימולטור או מכשיר במהלך הפיתוח, או מסביבת שילוב רציף (CI), אתם יכולים ליצור גרסת ניפוי באגים של האפליקציה שמשתמשת בספק ניפוי הבאגים של App Check במקום בספק אימות אמיתי.
שימוש בספק ניפוי הבאגים בפיתוח
כדי להשתמש בספק הניפוי באגים בזמן הפעלת האפליקציה באופן אינטראקטיבי (במהלך הפיתוח, למשל), מבצעים את הפעולות הבאות:
בגרסת הניפוי באגים, לפני שמשתמשים בשירותי עורף קצה של Firebase, צריך ליצור ולהגדיר את App Check debug provider factory:
FIRAppCheckDebugProviderFactory*providerFactory=[[FIRAppCheckDebugProviderFactoryalloc]init];[FIRAppChecksetAppCheckProviderFactory:providerFactory];// Use Firebase library to configure APIs[FIRAppconfigure];
בקטע App Check במסוף Firebase, בוחרים באפשרות ניהול אסימוני ניפוי באגים מתוך תפריט האפשרויות הנוספות של האפליקציה. לאחר מכן, רושמים את אסימון ניפוי הבאגים שנרשם בשלב הקודם.
אחרי שרושמים את האסימון, שירותי הקצה העורפי של Firebase יקבלו אותו כאסימון תקף.
הטוקן הזה מאפשר גישה למשאבי Firebase בלי מכשיר תקין, ולכן חשוב לשמור אותו בסודיות. אל תעלו אותו למאגר ציבורי, ואם טוקן רשום נפרץ, צריך לבטל אותו מיד במסוף Firebase.
שימוש בספק לניפוי באגים בסביבת CI
כדי להשתמש בספק לניפוי באגים בסביבת אינטגרציה רציפה (CI):
בקטע App Check במסוף Firebase, בוחרים באפשרות ניהול אסימוני ניפוי באגים מתוך תפריט האפשרויות הנוספות של האפליקציה. לאחר מכן, יוצרים טוקן חדש לניפוי באגים. תצטרכו את הטוקן בשלב הבא.
הטוקן הזה מאפשר גישה למשאבי Firebase בלי מכשיר תקין, ולכן חשוב לשמור אותו פרטי. אל תעלו אותו למאגר ציבורי, ואם טוקן רשום נפרץ, צריך לבטל אותו מיד במסוף Firebase.
מוסיפים את אסימון הניפוי הבאגים שיצרתם למאגר המפתחות המאובטח של מערכת ה-CI (לדוגמה, encrypted secrets ב-GitHub Actions או encrypted variables ב-Travis CI).
אם צריך, מגדירים את מערכת ה-CI כך שאסימון הניפוי הבאגים יהיה זמין בסביבת ה-CI כמשתנה סביבה. נותנים למשתנה שם כמו APP_CHECK_DEBUG_TOKEN_FROM_CI.
ב-Xcode, מוסיפים משתנה סביבה לתוכנית הבדיקה עם השם FIRAAppCheckDebugToken וערך כמו $(APP_CHECK_DEBUG_TOKEN).
מגדירים את סקריפט הבדיקה של CI כך שיעביר את אסימון הניפוי באגים כמשתנה סביבה. לדוגמה:
xcodebuild test -scheme YourTestScheme -workspace YourProject.xcworkspace \
APP_CHECK_DEBUG_TOKEN=$(APP_CHECK_DEBUG_TOKEN_FROM_CI)
בגרסת הניפוי באגים, לפני שמשתמשים בשירותי עורף קצה של Firebase, צריך ליצור ולהגדיר את App Check debug provider factory:
FIRAppCheckDebugProviderFactory*providerFactory=[[FIRAppCheckDebugProviderFactoryalloc]init];[FIRAppChecksetAppCheckProviderFactory:providerFactory];// Use Firebase library to configure APIs[FIRAppconfigure];
כשהאפליקציה פועלת בסביבת CI, שירותי ה-Backend של Firebase יקבלו את האסימון שהיא שולחת כחוקי.
[[["התוכן קל להבנה","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-09-03 (שעון UTC)."],[],[],null,["If, after you have registered your app for App Check, you want to run your\napp in an environment that App Check would normally not classify as valid,\nsuch as a simulator or device during development, or from a continuous\nintegration (CI) environment, you can create a debug build of your app that uses\nthe App Check debug provider instead of a real attestation provider.\n| **Warning:** The debug provider allows access to your Firebase resources from unverified devices. **Don't** use the debug provider in production builds of your app, and be careful not to leak your debug token.\n\nUse the debug provider in development\n\nTo use the debug provider while running your app interactively\n(during development, for example), do the following:\n\n1. In your debug build, before using any Firebase backend services, create and\n set the App Check debug provider factory:\n\n Swift \n\n ```swift\n let providerFactory = AppCheckDebugProviderFactory()\n AppCheck.setAppCheckProviderFactory(providerFactory)\n\n FirebaseApp.configure()\n ```\n\n Objective-C \n\n ```objective-c\n FIRAppCheckDebugProviderFactory *providerFactory =\n [[FIRAppCheckDebugProviderFactory alloc] init];\n [FIRAppCheck setAppCheckProviderFactory:providerFactory];\n\n // Use Firebase library to configure APIs\n [FIRApp configure];\n ```\n2. Enable debug logging in your Xcode project (v11.0 or newer):\n\n 1. Open **Product \\\u003e Scheme \\\u003e Edit scheme**.\n 2. Select **Run** from the left menu, then select the **Arguments** tab.\n 3. In the **Arguments Passed on Launch** section, add `-FIRDebugEnabled`.\n3. Launch the app. A local debug token will be logged when the SDK tries to\n send a request to the backend. For example:\n\n ```\n [Firebase/AppCheck][I-FAA001001] Firebase App Check Debug Token:\n 123a4567-b89c-12d3-e456-789012345678\n ```\n4. In the [**App Check**](//console.firebase.google.com/project/_/appcheck) section\n of the Firebase console, choose **Manage debug tokens** from your app's\n overflow menu. Then, register the debug token you logged in the previous\n step.\n\nAfter you register the token, Firebase backend services will accept it as valid.\n\nBecause this token allows access to your Firebase resources without a\nvalid device, it is crucial that you keep it private. Don't commit it to a\npublic repository, and if a registered token is ever compromised, revoke it\nimmediately in the Firebase console.\n\nUse the debug provider in a CI environment\n\nTo use the debug provider in a continuous integration (CI) environment, do the\nfollowing:\n\n1. In the [**App Check**](//console.firebase.google.com/project/_/appcheck) section\n of the Firebase console, choose **Manage debug tokens** from your app's\n overflow menu. Then, create a new debug token. You'll need the token in the\n next step.\n\n Because this token allows access to your Firebase resources without\n a valid device, it is crucial that you keep it private. Don't commit it to a\n public repository, and if a registered token is ever compromised, revoke it\n immediately in the Firebase console.\n\n2. Add the debug token you just created to your CI system's secure key store\n (for example, GitHub Actions' [encrypted secrets](https://docs.github.com/en/actions/reference/encrypted-secrets)\n or Travis CI's [encrypted variables](https://docs.travis-ci.com/user/environment-variables/#defining-encrypted-variables-in-travisyml)).\n\n3. If necessary, configure your CI system to make your debug token available\n within the CI environment as an environment variable. Name the variable\n something like `APP_CHECK_DEBUG_TOKEN_FROM_CI`.\n\n4. In Xcode, add an environment variable to your testing scheme with the name\n `FIRAAppCheckDebugToken` and something like `$(APP_CHECK_DEBUG_TOKEN)` as\n the value.\n\n5. Configure your CI test script to pass the debug token as an environment\n variable. For example:\n\n ```\n xcodebuild test -scheme YourTestScheme -workspace YourProject.xcworkspace \\\n APP_CHECK_DEBUG_TOKEN=$(APP_CHECK_DEBUG_TOKEN_FROM_CI)\n ```\n6. In your debug build, before using any Firebase backend services, create and\n set the App Check debug provider factory:\n\n Swift \n\n ```swift\n let providerFactory = AppCheckDebugProviderFactory()\n AppCheck.setAppCheckProviderFactory(providerFactory)\n\n FirebaseApp.configure()\n ```\n\n Objective-C \n\n ```objective-c\n FIRAppCheckDebugProviderFactory *providerFactory =\n [[FIRAppCheckDebugProviderFactory alloc] init];\n [FIRAppCheck setAppCheckProviderFactory:providerFactory];\n\n // Use Firebase library to configure APIs\n [FIRApp configure];\n ```\n\nWhen your app runs in a CI environment, Firebase backend services will accept\nthe token it sends as valid."]]