Skip to content

Poorgramer-Zack/dart-expert-skills / skills/firebase

integrating-firebase

Verified

Firebase integration for Flutter including Auth, Firestore, FCM, Cloud Storage, Analytics, and Crashlytics. Use when implementing serverless backend features, real-time sync, or push notifications.

FileKindSize
SKILL.mdskill md3.0 KB
references/analytics-crashlytics.mdmarkdown3.0 KB
references/app-check.mdmarkdown2.9 KB
references/auth.mdmarkdown6.2 KB
references/cost.mdmarkdown4.2 KB
references/database.mdmarkdown3.5 KB
references/messaging.mdmarkdown4.2 KB
references/serverpod-bff.mdmarkdown4.3 KB
references/setup.mdmarkdown2.7 KB
references/storage.mdmarkdown2.8 KB

references/app-check.md

View on GitHub
---
metadata:
  last_modified: "2026-03-12 11:18:17 (GMT+8)"
---

# App Check Security (`firebase_app_check`)

## Goal
Protect your Firebase backend resources (Firestore, Storage, Realtime Database, Cloud Functions) from abuse, billing fraud, and unauthorized API calls originating from bots, curl scripts, or modified emulators.

## Instructions

### The Necessity of App Check
Even if you write perfect Firestore Security Rules (`if request.auth != null`), anyone who extracts an active user's auth token can still write a Python script to bombard your database and run up your billing.

App Check solves this by proving that the API request is originating from a legitimate, unmodified Apple/Android device running your authentic application.

### Initialization Matrix
You must initialize App Check *immediately* after Firebase Core initialization. You need to configure a specific provider for each platform.

```dart
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);

  await FirebaseAppCheck.instance.activate(
    // Web: Requires a reCAPTCHA v3 site key
    providerWeb: ReCaptchaV3Provider('recaptcha-v3-site-key'),
    // Android: Play Integrity (the modern replacement for SafetyNet)
    providerAndroid: AndroidPlayIntegrityProvider(),
    // iOS: DeviceCheck (or AppleAppAttestProvider on iOS 14+)
    providerApple: AppleDeviceCheckProvider(),
  );

  runApp(const MyApp());
}
```

### Debug Providers (CRITICAL)
If you turn on App Check enforcement in the Firebase Console, your local iOS Simulators and Android Emulators **will instantly be blocked** from accessing Firestore because they are not "real" devices.

To fix this for local development, you must use the `DebugProvider`.

```dart
import 'package:flutter/foundation.dart';

// Inside main()
await FirebaseAppCheck.instance.activate(
  // Use debug providers during local kDebugMode development!
  providerAndroid: kDebugMode ? AndroidDebugProvider() : AndroidPlayIntegrityProvider(),
  providerApple: kDebugMode ? AppleDebugProvider() : AppleDeviceCheckProvider(),
);
```

When you run the app on an emulator for the first time with the Debug provider, a **Secret Debug Token** will be printed into your VSCode/Android Studio terminal. 
You MUST copy this token, go to the Firebase Console -> App Check -> Apps -> Manage Debug Tokens, and paste it there to whitelist your local emulator.

## Constraints
* **Firebase Console Enforcement:** Merely initializing the package in Flutter does nothing until you press "Enforce" on the specific product (e.g., Firestore) within the Firebase Console's App Check tab.
* **Grace Period:** NEVER turn on App Check "Enforcement" for an app that is already in production without giving users a few weeks to update their apps via the App Store/Play Store. Old app versions without the App Check SDK will be completely locked out of the database.
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall