capawesome-team / capacitor-firebase

⚡️ Firebase plugins for Capacitor. Supports Android, iOS and the Web.

Home Page:https://capawesome.io/plugins/firebase/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat: AppCheck Debug provider in Simulators

jjgriff93 opened this issue · comments

Plugin(s)

  • Analytics
  • App
  • App Check
  • Authentication
  • Crashlytics
  • Cloud Firestore
  • Cloud Messaging
  • Cloud Storage
  • Performance
  • Remote Config

Current problem

Currently this package does not work when running the Capacitor code from an iOS simulator, unless the debug flag is set when calling FirebaseAppCheck.initialize(). This is because simulators only support running with the AppCheckDebugProvider and will fail any real device checks.

Preferred solution

As per the Firebase docs, the following code could be implemented:

class MyAppCheckProviderFactory: NSObject, AppCheckProviderFactory {
  func createProvider(with app: FirebaseApp) -> AppCheckProvider? {
    #if targetEnvironment(simulator)
      // App Attest is not available on simulators.
      // Use a debug provider.
      return AppCheckDebugProvider(app: app)
    #else
      // Use App Attest provider on real devices.
      return AppAttestProvider(app: app)
    #endif
  }
}

Alternative options

No response

Additional context

No response

Before submitting

You can already select the debug provider using the initialize method. I'm therefore closing this issue.