Index
Methods
activate
-
Activate AppCheck
Parameters
-
provider: ReCaptchaV3Provider | ReCaptchaEnterpriseProvider | CustomProvider | AppCheckProvider | { getToken: () => AppCheckToken } | string
This can be a
ReCaptchaV3Provider
instance, aReCaptchaEnterpriseProvider
instance, aCustomProvider
instance, an object with a customgetToken()
method, or a reCAPTCHA site key. -
Optional isTokenAutoRefreshEnabled: boolean
If true, the SDK automatically refreshes App Check tokens as needed. If undefined, defaults to the value of
app.automaticDataCollectionEnabled
, which defaults to false and can be set in the app config.
Returns void
-
getToken
-
Get the current App Check token. Attaches to the most recent in-flight request if one is present. Returns null if no token is present and no token requests are in-flight.
Parameters
-
Optional forceRefresh: boolean
If true, will always try to fetch a fresh token. If false, will use a cached token if found in storage.
Returns Promise<AppCheckTokenResult>
-
onTokenChanged
-
Registers a listener to changes in the token state. There can be more than one listener registered at the same time for one or more App Check instances. The listeners call back on the UI thread whenever the current token associated with this App Check instance changes.
Parameters
-
observer: { complete?: () => void; error?: (error: Error) => void; next: (tokenResult: AppCheckTokenResult) => void }
An object with
next
,error
, andcomplete
properties.next
is called with anAppCheckTokenResult
whenever the token changes.error
is optional and is called if an error is thrown by the listener (thenext
function).complete
is unused, as the token stream is unending.-
Optional complete?: () => void
-
-
Returns void
-
-
-
Optional error?: (error: Error) => void
-
-
Parameters
-
error: Error
Returns void
-
-
-
-
next: (tokenResult: AppCheckTokenResult) => void
-
-
Parameters
-
tokenResult: AppCheckTokenResult
Returns void
-
-
-
-
Returns Unsubscribe
A function that unsubscribes this listener.
-
-
Registers a listener to changes in the token state. There can be more than one listener registered at the same time for one or more App Check instances. The listeners call back on the UI thread whenever the current token associated with this App Check instance changes.
Parameters
-
onNext: (tokenResult: AppCheckTokenResult) => void
When the token changes, this function is called with aa
AppCheckTokenResult
.-
-
Parameters
-
tokenResult: AppCheckTokenResult
Returns void
-
-
-
-
Optional onError: (error: Error) => void
Optional. Called if there is an error thrown by the listener (the
onNext
function).-
-
Parameters
-
error: Error
Returns void
-
-
-
-
Optional onCompletion: () => void
Currently unused, as the token stream is unending.
-
-
Returns void
-
-
Returns Unsubscribe
A function that unsubscribes this listener.
-
setTokenAutoRefreshEnabled
-
Parameters
-
isTokenAutoRefreshEnabled: boolean
If true, the SDK automatically refreshes App Check tokens as needed. This overrides any value set during
activate()
.
Returns void
-
The Firebase AppCheck service interface.
Do not call this constructor directly. Instead, use
firebase.appCheck()
.