Search code examples
swiftfirebase-app-check

Reuse Debug AppCheck token in iOS Simulator


I finished my ios app and now i want to implement appCheck on it. The problem is that when i'm running this in the simulator / real device but in debug mode, the token changes (not always, but sometimes) and i have to update the "debug tokens" from firebase console.

How can i reuse the tokens?

I find it hard to believe that i have to do these steps every time it changes, it's annoying.

I tried setting it up as here, not working enter image description here


Solution

  • Found the solution here.

    In case the link doesn't work:

    In edit scheme -> env variables set FIRAAppCheckDebugToken with a debug token

    In <project name>.entitlements App Attest Environment = production

    and in your app delegate or where you initialise your firebase code

            
    #if targetEnvironment (simulator)
            let providerFactory = AppCheckDebugProviderFactory()
            AppCheck.setAppCheckProviderFactory(providerFactory)
    #else
            let providerFactory = CustomAppCheckProviderFactory()
            AppCheck.setAppCheckProviderFactory(providerFactory)
    #endif
            
            FirebaseApp.configure()