initAppCheck function

void initAppCheck({
  1. String? app,
})

Binds App Check to an app: the default one, or the named one app. initDatabase or initNamedApp must have made the app first.

Only needed for appCheckToken, setAppCheckAutoRefresh, limitedUseAppCheckToken and appCheckTokenChanges; the other products attach tokens without it.

Implementation

void initAppCheck({String? app}) {
  ensureLibraryLoaded();
  if (!hasFirebase) throw StateError('this build has no Firebase SDK');
  final rc = _onApp(app, fdbAcInit);
  if (rc != 0) {
    throw StateError(
      rc != -1
          ? 'App Check instance could not be created ($rc)'
          : app == null || app.isEmpty
          ? 'initAppCheck before the Firebase app was initialized'
          : 'initAppCheck on "$app", which is not an app — call '
                'initNamedApp first',
    );
  }
}