An instance of AppCheck for FirebaseApp.defaultApp().
@throw Throws an exception if the default app is not configured yet or required FirebaseApp
options are missing.
NOTE: Make sure to call this method before FirebaseApp.configure(). If
this method is called after configuring Firebase, the changes will not take
effect.
If this flag is disabled then Firebase app check will not periodically auto-refresh the app
check token. The default value of the flag is equal to
FirebaseApp.dataCollectionDefaultEnabled. To disable the flag by default set
FirebaseAppCheckTokenAutoRefreshEnabled flag in the app Info.plist to NO. Once the flag is
set explicitly, the value will be persisted and used as a default value on next app launches.
Requests Firebase app check token. This method should only be used if you need to authorize
requests to a non-Firebase backend. Requests to Firebase backend are authorized automatically if
configured.
If your non-Firebase backend exposes sensitive or expensive endpoints that have low traffic
volume, consider protecting it with Replay
Protection.
In this case, use the limitedUseToken(completion:) instead to obtain a limited-use token.
If YES, a new Firebase app check token is requested and the token
cache is ignored. If NO, the cached token is used if it exists and has not expired yet. In
most cases, NO should be used. YES should only be used if the server explicitly returns an
error, indicating a revoked token.
handler
The completion handler. Includes the app check token if the request succeeds,
or an error if the request fails.
Requests a limited-use Firebase App Check token. This method should be used only if you need to
authorize requests to a non-Firebase backend.
Returns limited-use tokens that are intended for use with your non-Firebase backend endpoints
that are protected with Replay
Protection.
This method does not affect the token generation behavior of the
tokenForcingRefresh() method.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-11 UTC."],[],[],null,["# FirebaseAppCheck Framework Reference\n\nAppCheck\n========\n\n class AppCheck : NSObject\n\nA class used to manage app check tokens for a given Firebase app.\n- `\n ``\n ``\n `\n\n ### [-init](#/c:objc(cs)FIRAppCheck(im)init)\n\n `\n ` \n Unavailable \n Undocumented\n- `\n ``\n ``\n `\n\n ### [appCheck()](#/c:objc(cs)FIRAppCheck(cm)appCheck)\n\n `\n ` \n Returns a default instance of `AppCheck`. \n\n #### Declaration\n\n Swift \n\n class func appCheck() -\u003e Self\n\n #### Return Value\n\n An instance of `AppCheck` for `FirebaseApp.defaultApp()`.\n @throw Throws an exception if the default app is not configured yet or required `FirebaseApp`\n options are missing.\n- `\n ``\n ``\n `\n\n ### [appCheck(app:)](#/c:objc(cs)FIRAppCheck(cm)appCheckWithApp:)\n\n `\n ` \n Returns an instance of `AppCheck` for an application. \n\n #### Declaration\n\n Swift \n\n class func appCheck(app firebaseApp: FIRApp) -\u003e Self?\n\n #### Parameters\n\n |---------------------|------------------------------------------------|\n | ` `*firebaseApp*` ` | A configured `FirebaseApp` instance if exists. |\n\n #### Return Value\n\n An instance of `AppCheck` corresponding to the passed application.\n @throw Throws an exception if required `FirebaseApp` options are missing.\n- `\n ``\n ``\n `\n\n ### [setAppCheckProviderFactory(_:)](#/c:objc(cs)FIRAppCheck(cm)setAppCheckProviderFactory:)\n\n `\n ` \n Sets the [AppCheckProviderFactory](../Protocols/AppCheckProviderFactory.html) to use to generate\n [AppCheckDebugProvider](../Classes/AppCheckDebugProvider.html) objects.\n\n An instance of [DeviceCheckProviderFactory](../Classes.html#/c:objc(cs)FIRDeviceCheckProviderFactory) is used by default, but you can\n also use a custom [AppCheckProviderFactory](../Protocols/AppCheckProviderFactory.html) implementation or an\n instance of [AppCheckDebugProviderFactory](../Classes.html#/c:objc(cs)FIRAppCheckDebugProviderFactory) to test your app on a simulator\n on a local machine or a build server.\n\n NOTE: Make sure to call this method before `FirebaseApp.configure()`. If\n this method is called after configuring Firebase, the changes will not take\n effect. \n\n #### Declaration\n\n Swift \n\n class func setAppCheckProviderFactory(_ factory: (any FIRAppCheckProviderFactory)?)\n\n- `\n ``\n ``\n `\n\n ### [isTokenAutoRefreshEnabled](#/c:objc(cs)FIRAppCheck(py)isTokenAutoRefreshEnabled)\n\n `\n ` \n If this flag is disabled then Firebase app check will not periodically auto-refresh the app\n check token. The default value of the flag is equal to\n `FirebaseApp.dataCollectionDefaultEnabled`. To disable the flag by default set\n `FirebaseAppCheckTokenAutoRefreshEnabled` flag in the app Info.plist to `NO`. Once the flag is\n set explicitly, the value will be persisted and used as a default value on next app launches. \n\n #### Declaration\n\n Swift \n\n var isTokenAutoRefreshEnabled: Bool { get set }\n\n- `\n ``\n ``\n `\n\n ### [token(forcingRefresh:)](#/c:objc(cs)FIRAppCheck(im)tokenForcingRefresh:completion:)\n\n `\n ` \n Requests Firebase app check token. This method should *only* be used if you need to authorize\n requests to a non-Firebase backend. Requests to Firebase backend are authorized automatically if\n configured.\n\n If your non-Firebase backend exposes sensitive or expensive endpoints that have low traffic\n volume, consider protecting it with [Replay\n Protection](https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection).\n In this case, use the `limitedUseToken(completion:)` instead to obtain a limited-use token. \n\n #### Declaration\n\n Swift \n\n func token(forcingRefresh: Bool) async throws -\u003e FIRAppCheckToken\n\n #### Parameters\n\n |------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | ` `*forcingRefresh*` ` | If `YES`, a new Firebase app check token is requested and the token cache is ignored. If `NO`, the cached token is used if it exists and has not expired yet. In most cases, `NO` should be used. `YES` should only be used if the server explicitly returns an error, indicating a revoked token. |\n | ` `*handler*` ` | The completion handler. Includes the app check token if the request succeeds, or an error if the request fails. |\n\n- `\n ``\n ``\n `\n\n ### [limitedUseToken()](#/c:objc(cs)FIRAppCheck(im)limitedUseTokenWithCompletion:)\n\n `\n ` \n Requests a limited-use Firebase App Check token. This method should be used only if you need to\n authorize requests to a non-Firebase backend.\n\n Returns limited-use tokens that are intended for use with your non-Firebase backend endpoints\n that are protected with [Replay\n Protection](https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection).\n This method does not affect the token generation behavior of the\n `tokenForcingRefresh()` method. \n\n #### Declaration\n\n Swift \n\n func limitedUseToken() async throws -\u003e FIRAppCheckToken"]]