استخدام ميزة "التحقّق من التطبيقات" مع موفِّر تصحيح الأخطاء مع Flutter
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
بعد تسجيل تطبيقك في App Check، لن يتم تشغيله عادةً في محاكي أو من بيئة دمج متواصل (CI)، لأنّ هذه البيئات لا تُعد أجهزة صالحة. إذا كنت تريد تشغيل تطبيقك في مثل هذه البيئة أثناء عملية التطوير والاختبار، يمكنك إنشاء إصدار تصحيح أخطاء من تطبيقك يستخدم موفّر تصحيح الأخطاء في App Check بدلاً من موفّر إثبات صحة حقيقي.
منصات Apple
لاستخدام موفّر تصحيح الأخطاء أثناء تشغيل تطبيقك في محاكي بشكل تفاعلي (أثناء التطوير مثلاً)، اتّبِع الخطوات التالية:
فعِّل App Check باستخدام موفّر التصحيح مباشرةً بعد إعداد تطبيقك على Firebase:
import'package:flutter/material.dart';import'package:firebase_core/firebase_core.dart';// Import the firebase_app_check pluginimport'package:firebase_app_check/firebase_app_check.dart';Future<void>main()async{WidgetsFlutterBinding.ensureInitialized();awaitFirebase.initializeApp();awaitFirebaseAppCheck.instance.activate(// Set appleProvider to `AppleProvider.debug`appleProvider:AppleProvider.debug,);runApp(App());}
فعِّل تسجيل معلومات تصحيح الأخطاء في مشروع Xcode (الإصدار 11.0 أو إصدار أحدث):
انقر على تشغيل (Run) من القائمة اليمنى، ثمّ انقر على علامة التبويب الوسيطات (Arguments).
في قسم المَعلمات التي تم ضبطها عند الإطلاق (Arguments Passed on Launch)، أضِف -FIRDebugEnabled.
افتح ios/Runner.xcworkspace باستخدام Xcode وشغِّل تطبيقك في المحاكي.
سيطبع تطبيقك رمز تصحيح أخطاء محليًا في ناتج تصحيح الأخطاء عندما تحاول Firebase إرسال طلب إلى الخلفية. على سبيل المثال:
في قسم App Check ضمن وحدة تحكّم Firebase، اختَر إدارة رموز تصحيح الأخطاء من قائمة الخيارات الإضافية في تطبيقك. بعد ذلك، سجِّل الرمز المميّز لتصحيح الأخطاء الذي سجّلته في الخطوة السابقة.
بعد تسجيل الرمز المميّز، ستقبله خدمات الخلفية في Firebase على أنّه صالح.
بما أنّ هذا الرمز المميّز يتيح الوصول إلى موارد Firebase بدون جهاز صالح، من الضروري الحفاظ على خصوصيته. لا ترسِل الرمز المميّز إلى مستودع عام، وإذا تم اختراق رمز مميّز مسجّل، عليك إبطاله على الفور في وحدة تحكّم Firebase.
Android
لاستخدام موفّر تصحيح الأخطاء أثناء تشغيل تطبيق Flutter في بيئة Android، نفِّذ الرمز التالي في تطبيق Flutter:
import'package:flutter/material.dart';import'package:firebase_core/firebase_core.dart';// Import the firebase_app_check pluginimport'package:firebase_app_check/firebase_app_check.dart';Future<void>main()async{WidgetsFlutterBinding.ensureInitialized();awaitFirebase.initializeApp();awaitFirebaseAppCheck.instance.activate(webRecaptchaSiteKey:'recaptcha-v3-site-key',// Set androidProvider to `AndroidProvider.debug`androidProvider:AndroidProvider.debug,);runApp(App());}
سيطبع تطبيقك رمز تصحيح أخطاء محليًا في ناتج تصحيح الأخطاء عندما تحاول Firebase
إرسال طلب إلى الخلفية. على سبيل المثال:
D DebugAppCheckProvider: Enter this debug secret into the allow list in
the Firebase Console for your project: 123a4567-b89c-12d3-e456-789012345678
في قسم App Check ضمن وحدة تحكّم Firebase، اختَر إدارة رموز تصحيح الأخطاء من قائمة الخيارات الإضافية في تطبيقك. بعد ذلك، سجِّل الرمز المميّز لتصحيح الأخطاء الذي سجّلته في الخطوة السابقة.
بعد تسجيل الرمز المميّز، ستقبله خدمات الخلفية في Firebase على أنّه صالح.
الويب
لاستخدام موفّر تصحيح الأخطاء أثناء تشغيل تطبيقك من localhost (أثناء عملية التطوير مثلاً)، اتّبِع الخطوات التالية:
في الملف web/index.html، فعِّل وضع تصحيح الأخطاء من خلال ضبط
self.FIREBASE_APPCHECK_DEBUG_TOKEN على true:
شغِّل تطبيق الويب على جهازك وافتح أداة المطوّر في المتصفّح. في
وحدة تصحيح الأخطاء، سيظهر رمز مميّز لتصحيح الأخطاء:
AppCheck debug token: "123a4567-b89c-12d3-e456-789012345678". You will
need to safelist it in the Firebase console for it to work.
يتم تخزين هذا الرمز المميز محليًا في متصفحك وسيتم استخدامه كلما استخدمت تطبيقك في المتصفح نفسه على الجهاز نفسه. إذا أردت استخدام الرمز المميّز في متصفّح آخر أو على جهاز آخر، اضبط قيمة self.FIREBASE_APPCHECK_DEBUG_TOKEN على سلسلة الرمز المميّز بدلاً من true.
في قسم App Check ضمن وحدة تحكّم Firebase، اختَر إدارة رموز تصحيح الأخطاء من قائمة الخيارات الإضافية في تطبيقك. بعد ذلك، سجِّل الرمز المميّز لتصحيح الأخطاء الذي سجّلته في الخطوة السابقة.
بعد تسجيل الرمز المميّز، ستقبله خدمات الخلفية في Firebase على أنّه صالح.
بما أنّ هذا الرمز المميّز يتيح الوصول إلى موارد Firebase بدون جهاز صالح، من الضروري الحفاظ على خصوصيته. لا ترسِل الرمز المميّز إلى مستودع عام، وإذا تم اختراق رمز مميّز مسجّل، عليك إبطاله على الفور في وحدة تحكّم Firebase.
تاريخ التعديل الأخير: 2025-08-23 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-23 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["After you have registered your app for App Check, your app normally won't run\nin an emulator or from a continuous integration (CI) environment, since those\nenvironments don't qualify as valid devices. If you want to run your app in such\nan environment during development and testing, you can create a debug build of\nyour app that uses the App Check debug provider instead of a real attestation\nprovider.\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 don't share your debug builds with untrusted parties.\n\nApple platforms\n\nTo use the debug provider while running your app in a simulator interactively\n(during development, for example), do the following:\n\n1. Activate App Check with the debug provider right after you have initialized\n your Firebase app:\n\n import 'package:flutter/material.dart';\n import 'package:firebase_core/firebase_core.dart';\n\n // Import the firebase_app_check plugin\n import 'package:firebase_app_check/firebase_app_check.dart';\n\n Future\u003cvoid\u003e main() async {\n WidgetsFlutterBinding.ensureInitialized();\n await Firebase.initializeApp();\n await FirebaseAppCheck.instance.activate(\n // Set appleProvider to `AppleProvider.debug`\n appleProvider: AppleProvider.debug,\n );\n runApp(App());\n }\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. Open `ios/Runner.xcworkspace` with Xcode and run your app in the Simulator.\n Your app will print a local debug token to the debug output when Firebase\n tries to send a request to the backend. For example:\n\n ```\n 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\nAndroid\n\nTo use the debug provider while running your Flutter app in an Android environment,\nimplement the following code in your Flutter application: \n\n import 'package:flutter/material.dart';\n import 'package:firebase_core/firebase_core.dart';\n\n // Import the firebase_app_check plugin\n import 'package:firebase_app_check/firebase_app_check.dart';\n\n Future\u003cvoid\u003e main() async {\n WidgetsFlutterBinding.ensureInitialized();\n await Firebase.initializeApp();\n await FirebaseAppCheck.instance.activate(\n webRecaptchaSiteKey: 'recaptcha-v3-site-key',\n // Set androidProvider to `AndroidProvider.debug`\n androidProvider: AndroidProvider.debug,\n );\n runApp(App());\n }\n\nYour app will print a local debug token to the debug output when Firebase tries\nto send a request to the backend. For example: \n\n```\nD DebugAppCheckProvider: Enter this debug secret into the allow list in\nthe Firebase Console for your project: 123a4567-b89c-12d3-e456-789012345678\n```\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, 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\nWeb\n\nTo use the debug provider while running your app from `localhost` (during\ndevelopment, for example), do the following:\n| **Warning:** *Do not* try to enable `localhost` debugging by adding `localhost` to reCAPTCHA's allowed domains. Doing so would allow anyone to run your app from their local machines!\n\n1. In the file `web/index.html`, enable debug mode by setting\n `self.FIREBASE_APPCHECK_DEBUG_TOKEN` to `true`:\n\n \u003cbody\u003e\n \u003cscript\u003e\n self.FIREBASE_APPCHECK_DEBUG_TOKEN = true;\n \u003c/script\u003e\n\n ...\n\n \u003c/body\u003e\n\n2. Run your web app locally and open the browser's developer tool. In the\n debug console, you'll see a debug token:\n\n ```\n AppCheck debug token: \"123a4567-b89c-12d3-e456-789012345678\". You will\n need to safelist it in the Firebase console for it to work.\n ```\n\n This token is stored locally in your browser and will be used whenever you\n use your app in the same browser on the same machine. If you want to use the\n token in another browser or on another machine, set\n `self.FIREBASE_APPCHECK_DEBUG_TOKEN` to the token string instead of `true`.\n3. 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."]]