appInitAppCheck function
Activates Firebase App Check per config — bounded + non-critical.
No-op when config is null (opt-out). Otherwise selects providers, activates
within AppCheckConfig.activationTimeout, enables auto-refresh, and on ANY
timeout/failure REPORTS via reportBootstrapDiagnostic (so it reaches the
backend whether the reporter attached before Firebase — Sentry early-attach —
or after — Crashlytics, deferred + flushed) and CONTINUES. The in-flight
activate (if it timed out) completes in the background and serves later
lazily-attested calls.
Idempotent across gate-retry re-runs: re-activation is a no-op-ish reconfigure in the underlying SDK, and the debug-token globals are apply-once.
No-op when config is null (opt-out by omission) OR when
AppConfigBase.appCheckEnabled is false (the per-build APP_CHECK_ENABLED
kill switch).
Implementation
Future<void> appInitAppCheck(AppCheckConfig? config) async {
if (config == null) {
return;
}
if (!AppConfigBase.appCheckEnabled) {
logBreadcrumb('appInitAppCheck: skipped (APP_CHECK_ENABLED=false)',
category: 'bootstrap');
return;
}
logBreadcrumb('appInitAppCheck: activating '
'(debugProviders=${AppConfigBase.appCheckUseDebugProviders})',
category: 'bootstrap');
final activate = debugAppCheckActivatorOverride ?? _activateFirebaseAppCheck;
try {
await activate(config).timeout(config.activationTimeout);
logBreadcrumb('appInitAppCheck: activated', category: 'bootstrap');
} catch (e, st) {
reportBootstrapDiagnostic(
e,
'App Check activation timed out or failed — continuing boot; App Check '
'will attest lazily on the first attested callable',
st,
);
}
}