So I recently started setting up app check for my existing Flutter project (for both android and iOS platforms). I've had no problem with android's "Play Integrity", got the necessary debug token, and can successfully send and retrieve data to/from firestore (app check for firestore is currently enforced for my project).
The problem is, I can not get such a debug key for my iOS app. I will list the sources I've used and what I've tried so far.
- I have
firebase_app_check: ^0.1.1+8
installed via pubspec.yaml - I also added
pod 'FirebaseAppCheck'
to my Podfile - I have the necessary initialization code in my
main.dart
:await FirebaseAppCheck.instance.activate(...);
- For "DeviceCheck", I am using THE SAME private key that I am using for "Sign in With Apple" (which I have implemented successfully). I have also enabled the checkbox for DeviceCheck in the settings of that private key (in Apple Developer).
- For my App ID (Apple Developer > Identifiers > App IDs), I have also enabled the checkbox for "App Attest".
- I have put "-FIRDebugEnabled" as an argument passed on launch in XCode > Product > Scheme > Edit Scheme.
- I always uninstall my app from my iOS simulator (iOS 16.2) or real device (iOS 16.1.2), before trying again, because I have read across multiple forums that the debug token only gets printed to the output the first time you run your app.
- I have also added these 4 lines of code in my AppDelegate.swift from here:
#if DEBUG
let providerFactory = AppCheckDebugProviderFactory()
AppCheck.setAppCheckProviderFactory(providerFactory)
#endif
Official firebase docs "iOS+ (App Attest)":
I have NOT copied ANY code from this page of the official docs, as I assume it's for native iOS apps only, and not for flutter, and I don't know where exactly I would have to put that code. I have only added the pod dependency and run pod install.
I don't have a .entitlements
file.
So after all those steps, I'm apparently supposed to expect to find a debug token in my run output, as in:
Yet the only relevant output I can find is the following:
Runner[72719:33546579] 10.3.0 - [FirebaseFirestore][I-FST000001] AppCheck failed: 'The operation couldn’t be completed. (com.apple.devicecheck.error error 1.)'
If it matters:
I have NOT YET uploaded my iOS app to apple developer, app store connect or whatever (I'm not yet familiar with the process of publishing to the app store).
Neither have I uploaded my android app to Google Play console or created an app there (for this project).
Don't tell me anything about firestore rules. I already had that set up long ago, and everything worked just fine before I started integrating App Check.
Don't recommend any 3rd party plugins to me, I will only use official ones.
The firebase documentation says:
Try removing the '#if DEBUG' and '#endif' and run the app. If it works, it mean you have missed that step
I was not able to find that build setting, so i just removed those lines from the AppDelegate, but i need to keep in mind to remove the other 2 lines while building the release mode