이 페이지에서는 Android의 Play Integrity, Apple 플랫폼의 Device Check, 웹의 reCAPTCHA v3 등 기본 제공업체를 사용하여 Flutter 앱에서 앱 체크를 사용 설정하는 방법을 설명합니다. 앱 체크를 사용 설정하면 사용자의 앱만 프로젝트의 Firebase 리소스에 액세스할 수 있습니다. 이 기능의 개요를 참조하세요.
Firebase Console의 프로젝트 설정 > 앱 체크 섹션에서 Play Integrity, Device Check 및 reCAPTCHA 제공업체에 앱 체크를 사용하도록 앱을 등록합니다.
Firebase 제품에 적용을 사용 설정하면 등록된 앱만 제품의 백엔드 리소스에 액세스할 수 있으므로 일반적으로 프로젝트의 모든 앱을 등록해야 합니다.
선택사항: 앱 등록 설정에서 제공자가 발급한 앱 체크 토큰의 커스텀 TTL(수명)을 설정합니다. TTL은 30분에서 7일 사이의 값으로 설정할 수 있습니다. 이 값을 변경할 때는 다음 장단점을 고려하세요.
보안: TTL이 짧을수록 유출되거나 가로채인 토큰이 공격자에 의해 악용될 수 있는 기간이 줄어들므로 보안이 강화됩니다.
성능: TTL이 짧을수록 앱에서 증명을 더 자주 수행합니다. 앱 증명 프로세스는 실행될 때마다 네트워크 요청에 지연 시간이 추가되므로 짧은 TTL은 앱 성능에 영향을 줄 수 있습니다.
할당량 및 비용: 더 짧은 TTL과 빈번한 재증명으로 인해 할당량이 더 빨리 소진되며, 유료 서비스의 경우 더 많은 비용이 발생할 수 있습니다.
할당량 및 한도를 참조하세요.
대부분의 앱에 기본 TTL이 적합합니다. 앱 체크 라이브러리는 TTL 기간의 약 절반이 지났을 때 토큰을 새로고침합니다.
2. 앱에 앱 체크 라이브러리 추가
Flutter 프로젝트 루트에서 다음 명령어를 실행하여 플러그인을 설치합니다.
flutterpubaddfirebase_app_check
완료되면 Flutter 애플리케이션을 다시 빌드합니다.
flutterrun
3. 앱 체크 초기화
Firebase.initializeApp()을 호출한 후 Storage와 같은 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(// You can also use a `ReCaptchaEnterpriseProvider` provider instance as an// argument for `webProvider`webProvider:ReCaptchaV3Provider('recaptcha-v3-site-key'),// Default provider for Android is the Play Integrity provider. You can use the "AndroidProvider" enum to choose// your preferred provider. Choose from:// 1. Debug provider// 2. Safety Net provider// 3. Play Integrity providerandroidProvider:AndroidProvider.debug,// Default provider for iOS/macOS is the Device Check provider. You can use the "AppleProvider" enum to choose// your preferred provider. Choose from:// 1. Debug provider// 2. Device Check provider// 3. App Attest provider// 4. App Attest provider with fallback to Device Check provider (App Attest provider is only available on iOS 14.0+, macOS 14.0+)appleProvider:AppleProvider.appAttest,);runApp(App());}
다음 단계
앱에 앱 체크 라이브러리가 설치되면 업데이트된 앱을 사용자에게 배포하기 시작합니다.
업데이트된 클라이언트 앱이 Firebase에 전송하는 모든 요청과 함께 앱 체크 토큰을 보내기 시작하지만 Firebase 제품에서는 Firebase Console의 앱 체크 섹션에서 적용을 사용 설정할 때까지 토큰이 유효하지 않아도 됩니다.
측정항목 모니터링 및 적용 사용 설정
적용을 사용 설정하기 전에 먼저 이렇게 해도 기존의 정당한 사용자에게 불편을 야기하지 않는지 확인해야 합니다. 반면에 앱 리소스 사용이 의심스러워 보이면 적용을 더 빠르게 사용 설정하는 것이 좋습니다.
사용 중인 서비스의 앱 체크 측정항목을 확인하면 적용 여부에 대한 판단을 내리는 데 도움이 됩니다.
실시간 데이터베이스, Cloud Firestore, Cloud Storage, 인증에 대한 앱 체크 요청 측정항목을 모니터링합니다.
[null,null,["최종 업데이트: 2025-08-18(UTC)"],[],[],null,["\u003cbr /\u003e\n\nThis page shows you how to enable App Check in a Flutter app, using the\ndefault providers: Play Integrity on Android, Device Check on Apple platforms, and\nreCAPTCHA v3 on web. When you enable App Check, you help ensure that\nonly your app can access your project's Firebase resources. See an\n[Overview](/docs/app-check) of this feature.\n\n1. Set up your Firebase project\n\n1. [Install and initialize FlutterFire](/docs/flutter/setup) if you haven't\n already done so.\n\n2. Register your apps to use App Check with the Play Integrity, Device Check, and reCAPTCHA providers in the\n [**Project Settings \\\u003e App Check**](https://console.firebase.google.com/project/_/appcheck)\n section of the Firebase console.\n\n You usually need to register all of your project's apps, because once you\n enable enforcement for a Firebase product, only registered apps will be able\n to access the product's backend resources.\n3. **Optional**: In the app registration settings, set a custom time-to-live\n (TTL) for App Check tokens issued by the provider. You can set the TTL\n to any value between 30 minutes and 7 days. When changing this value, be\n aware of the following tradeoffs:\n\n - Security: Shorter TTLs provide stronger security, because it reduces the window in which a leaked or intercepted token can be abused by an attacker.\n - Performance: Shorter TTLs mean your app will perform attestation more frequently. Because the app attestation process adds latency to network requests every time it's performed, a short TTL can impact the performance of your app.\n - Quota and cost: Shorter TTLs and frequent re-attestation deplete your quota faster, and for paid services, potentially cost more. See [Quotas \\& limits](/docs/app-check#quotas_limits).\n\n The default TTL\n is reasonable for most apps. Note that the App Check library refreshes\n tokens at approximately half the TTL duration.\n\n2. Add the App Check library to your app\n\n1. From the root of your Flutter project, run the following command to install the plugin:\n\n flutter pub add firebase_app_check\n\n2. Once complete, rebuild your Flutter application:\n\n flutter run\n\n3. Initialize App Check\n\nAdd the following initialization code to your app so that it runs before you\nuse any Firebase services such as Storage, but after calling\n`Firebase.initializeApp()`; \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 // You can also use a `ReCaptchaEnterpriseProvider` provider instance as an\n // argument for `webProvider`\n webProvider: ReCaptchaV3Provider('recaptcha-v3-site-key'),\n // Default provider for Android is the Play Integrity provider. You can use the \"AndroidProvider\" enum to choose\n // your preferred provider. Choose from:\n // 1. Debug provider\n // 2. Safety Net provider\n // 3. Play Integrity provider\n androidProvider: AndroidProvider.debug,\n // Default provider for iOS/macOS is the Device Check provider. You can use the \"AppleProvider\" enum to choose\n // your preferred provider. Choose from:\n // 1. Debug provider\n // 2. Device Check provider\n // 3. App Attest provider\n // 4. App Attest provider with fallback to Device Check provider (App Attest provider is only available on iOS 14.0+, macOS 14.0+)\n appleProvider: AppleProvider.appAttest,\n );\n runApp(App());\n }\n\nNext steps\n\nOnce the App Check library is installed in your app, start distributing the\nupdated app to your users.\n\nThe updated client app will begin sending App Check tokens along with every\nrequest it makes to Firebase, but Firebase products will not require the tokens\nto be valid until you enable enforcement in the App Check section of the\nFirebase console.\n\nMonitor metrics and enable enforcement\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 App Check metrics for the\nservices you use:\n\n- [Monitor App Check request metrics](/docs/app-check/monitor-metrics) for Realtime Database, Cloud Firestore, Cloud Storage, and Authentication.\n- [Monitor App Check request metrics for Cloud Functions](/docs/app-check/monitor-functions-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:\n\n- [Enable App Check enforcement](/docs/app-check/enable-enforcement) for Realtime Database, Cloud Firestore, Cloud Storage, and Authentication.\n- [Enable App Check enforcement for Cloud Functions](/docs/app-check/cloud-functions).\n\nUse App Check in debug environments\n\nIf, 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 an emulator during development, or from a continuous integration (CI)\nenvironment, you can create a debug build of your app that uses the\nApp Check debug provider instead of a real attestation provider.\n\nSee [Use App Check with the debug provider in Flutter apps](/docs/app-check/flutter/debug-provider).\n| **Note:** For certain Android devices, you need to enable \"Meets basic device integrity\" in the Google Play console."]]