1

I've implemented AppCheck using the instructions here: https://firebase.google.com/docs/app-check/flutter/default-providers

I've verified that I call this (after firebase initiazlization): await FirebaseAppCheck.instance.activate();

When testing my app locally, on iOS emulator, I get permission-denied when trying to read / write to Firestore.

More details:

  1. Trying to read documents from Firestore (used to work before AppCheck enforcement)
  2. DB security rules allow read / write to authenticated users who made the request (tested in "Rules Playground" and used to work before AppCheck enforcement)

Do I need to setup anything in order to test my app on the emulator? Am I missing anything? Does it have anything to do with this (no flutter mentioned there): https://firebase.google.com/docs/app-check/ios/debug-provider

user6097845
  • 1,257
  • 1
  • 15
  • 33
  • Please edit the question to provide the code that doesn't work the way you expect, your security rules, and the steps you take to reproduce the issue. – Doug Stevenson Jun 08 '22 at 15:21
  • I've added (under "More details") some more info. I hope it helps. I'll gladly add any other relevant info – user6097845 Jun 08 '22 at 15:35
  • Please read my previous comment again for things to add to the question. We can't reproduce this given the information you've shown so far. – Doug Stevenson Jun 08 '22 at 15:39
  • Thanks for your comment. I have read the original comment, but it's a bit of an issue to provide the code and the security rules since they are specific to my DB (I prefer not to expose my DB structure and I guess I won't help you much)... Is it possible that I get these issue since I run my app with a debug version on iOS emulator? – user6097845 Jun 08 '22 at 16:11
  • If we can't see your code, then we won't be able to tell if you're doing something wrong. On Stack Overflow, it's expected that questions provide a [complete minimal example](https://stackoverflow.com/help/minimal-reproducible-example) that illustrates the problem. – Doug Stevenson Jun 08 '22 at 17:31
  • Did you find a solution meanwhile? I just opened another question: https://stackoverflow.com/q/72908766/2154784 – valley Jul 08 '22 at 09:10
  • It works for me on the device itself, in release, not on the emulator – user6097845 Aug 29 '22 at 15:02

1 Answers1

0

Use the debug provider and add a debug token to Firebase.

See Use App Check with the debug provider with Flutter.

Something like this for iOS:

@objc class AppDelegate: FlutterAppDelegate {
    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        let providerFactory = AppCheckDebugProviderFactory()
        AppCheck.setAppCheckProviderFactory(providerFactory)

        FirebaseApp.configure()
...
user18309290
  • 5,777
  • 2
  • 4
  • 22
  • I suspect that's the problem. It's unclear to me how to add the Swift / Objective-C code shown there in my Flutter app... – user6097845 Jun 08 '22 at 16:08