Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@nativescript/firebase-app-check

NativeScript271Apache-2.05.0.2TypeScript support: included

NativeScript Firebase - App Check

NativeScript, JavaScript, TypeScript, iOS, Android, Firebase, AppCheck, Attestation, Security, Tamper

readme

@nativescript/firebase-app-check

npm install @nativescript/firebase-app-check

Note: (iOS) App Check requires you set the minimum iOS Deployment version in ios/Podfile to 11.0 or greater.

What does it do

App Check works alongside other Firebase services to help protect your backend resources from abuse, such as billing fraud or phishing. With App Check, devices running your app will use an app or device attestation provider that attests to one or both of the following:

Requests originate from your authentic app Requests originate from an authentic, untampered device This attestation is attached to every request your app makes to your Firebase backend resources.

image

This App Check module has built-in support for using the following services as attestation providers:

DeviceCheck on iOS SafetyNet on Android App Check currently works with the following Firebase products:

Realtime Database Cloud Storage Cloud Functions (callable functions) The official Firebase App Check documentation has more information, including about the iOS AppAttest provider, and testing/ CI integration, it is worth a read.

Usage

Activate

import { firebase } from '@nativescript/firebase-core';
import { AppCheck } from '@nativescript/firebase-app-check';

AppCheck.setProviderFactory(); // call before the fb app is initialized 
firebase.initializeApp()
.then(app =>{
    firebase().appCheck().activate(true);
})

The only configuration possible is the token auto refresh. When you call activate, the provider stays the same but the token auto refresh setting will be changed based on the argument provided.

You must call activate prior to calling any firebase back-end services for App Check to function.

Custom Provider

import { firebase } from '@nativescript/firebase-core';
import { AppCheck, AppCheckProviderFactory, AppCheckProvider } from '@nativescript/firebase-app-check';


class AppCheckProviderFactoryImpl extends AppCheckProviderFactory {
    createProvider(app: FirebaseApp) {
        // we could potentiall do something with the app 
        return new AppCheckProviderImpl();
    }
}


class AppCheckProviderImpl extends AppCheckProvider {
    getToken(done){
        // do some call probably http
        // finally call done when you're ready passing in a token along with the expirationDate
        done({
            token: someToken,
            expirationDate: someDate 
        })
    }
}



AppCheck.setProviderFactory(new AppCheckProviderFactoryImpl()); // call before the fb app is initialized 
firebase.initializeApp()
.then(app =>{
    firebase().appCheck().activate(true);
})

Automatic Data Collection

App Check has an "tokenAutoRefreshEnabled" setting. This may cause App Check to attempt a remote App Check token fetch prior to user consent. In certain scenarios, like those that exist in GDPR-compliant apps running for the first time, this may be unwanted.

If unset, the "tokenAutoRefreshEnabled" setting will defer to the app's "automatic data collection" setting, which may be set in the Info.plist or AndroidManifest.xml

Using App Check tokens for non-firebase services

The official documentation shows how to use getToken to access the current App Check token and then verify it in external services.

License

Apache License Version 2.0

changelog

5.0.0 (2025-05-13)

Features

BREAKING CHANGES

3.3.2 (2024-08-30)

Bug Fixes

  • messaging: null reference when getting current token (#266) (ff516e0)

3.3.1 (2024-05-03)

Features

3.3.0 (2024-05-02)

Bug Fixes

  • core: initializeApp default app not resolved (#255) (486294b)
  • ios: cleaning firebase-messaging-core iOS build warnings (#251) (872c1c2)

Features

  • analytics: iOS SDK 10.24+ (#257) (d8ff8d6)
  • support async callbacks for messages and notification taps (#252) (86a2723)

3.2.0 (2023-09-24)

Features

3.1.3 (2023-07-19)

Bug Fixes

  • analytics: long/double handling for android (#225) (14c26bb)
  • analytics: typings (9251d5c)

3.0.0-alpha.0 (2023-03-23)

Bug Fixes

  • crashlytics/ios: record stacktrace for JS errors (#177) (155cae4)
  • remove buildShortDynamicLink call (#179) (85c3a4f)

Features

2.5.2 (2022-12-27)

Bug Fixes

  • firebase-analytics: consistent handling of Podfile variable $NSFirebaseAnalyticsWithoutAdIdSupport (#167) (7ca3c04)
  • messaging: fcm token callback not fired (4f97aab)

2.5.1 (2022-12-12)

Bug Fixes

  • dynamicLinks: create social builder (a28125f)
  • dynamicLinks: demo (f8ef50c)
  • dynamicLinks: missing setters (a647937)

2.5.0 (2022-12-12)

Bug Fixes

  • dynamic-links: build link before generating long link (#164) (c60775d)
  • dynamic-links: export ShortLinkType as an object (#161) (050e7b9)
  • dynamic-links: instance check (d499eec)
  • dynamic-links: ios parameters builder assigned to wrong variable (#162) (a4a5c45)
  • firestore)(android: arrayUnion always appends null to array (#150) (e1b09f5)
  • firestore: update settings on firestore instance (089b92e)
  • ios/core: filter out nil values from serialize method (#142) (1033984)
  • messaging: Activity registerForActivityResult is not a function (#155) (94f93d2)
  • messaging: delay android messages only until a listener is added (#165) (7b898c4)

Features

  • dynamic-links: support short links on iOS (#163) (3ff4889)

2.4.4 (2022-10-31)

Bug Fixes

  • auth: ios providerData properties undefined (#145) (0836a95)
  • messaging: readme file rename instructions do not work (#146) (162e9d8)

2.4.3 (2022-10-28)

Bug Fixes

  • messaging-core: check permission results size (14b99c8), closes #144

2.4.2 (2022-10-28)

Bug Fixes

  • admob: use content-view (ab32015)
  • auth: languageCode (95122cb)
  • firestore: onSnapshot handling (c74f67a)

2.4.1 (2022-10-19)

Bug Fixes

  • admob: export correct enums (161af8a)
  • database: export (24614e3)
  • firestore: onSnapshot handling (ba384c2)

2.4.0 (2022-10-13)

Bug Fixes

  • admob: import (9c77fa2), closes #140
  • analytics: hook multiple writes (0e00cdc)
  • firestore: fieldPath as key (c4ae70f)
  • firestore: iOS nested FieldValues not serialized in update() (#139) (7f6da0b)

2.4.0-alpha.0 (2022-09-21)

Features

2.3.4 (2022-09-04)

Bug Fixes

  • messaging: promise resolve (0db80d4)

2.3.3 (2022-09-03)

Bug Fixes

  • messaging: handle late permissions request (b95d56c)

2.3.2 (2022-09-03)

Bug Fixes

2.3.1 (2022-09-02)

Bug Fixes

  • messaging: API 33 permission request (39b3b89)

2.3.0 (2022-08-27)

Bug Fixes

  • admob independence , cloud-messaging notification emitting, database unsubscribing & initial dynamicLink (#121) (9908b76), closes #117 #116 #120

2.2.9 (2022-08-08)

Bug Fixes

  • analytics: AnalyticsWithoutAdIdSupport (#115) (9f2d612)
  • analytics: missing postinstall - removing for now (e66578d)
  • database: issue with date handling and accepted ios types (de62bfb)

2.2.7 (2022-08-06)

Bug Fixes

  • database: Set decimal value (bf6c2c5), closes #113
  • database: Unsubscribe to event doesn't work (bda9f9c), closes #109
  • dynamicLinks: initial crash (f052651), closes #111
  • messaging: TNSFirebaseMessaging is not defined (9e129bc), closes #112
  • messaging: Typings for reexported Types that are used in the method definitions (#114) (452fee4)

2.2.6 (2022-08-02)

Bug Fixes

2.2.5 (2022-08-02)

Bug Fixes

2.2.4 (2022-08-02)

Bug Fixes

2.2.3 (2022-07-29)

Bug Fixes

  • database: null handling (1cd39e9)

2.2.2 (2022-07-28)

Bug Fixes

  • messaging: include messaging-core dep (93cfc78)

2.2.1 (2022-07-28)

Bug Fixes

  • core: wrap null as NSNull when wrapping primitives (0e81ad9)

2.2.0 (2022-07-28)

Bug Fixes

  • admob: BannerAdlistener not defined (2ee0bcf), closes #97
  • admob: request configuration ignored (9d06c1e), closes #103
  • database: handle null serialize (e49d15b), closes #105
  • database: setPersistenceEnabled called multiple times (73c2d72), closes #91
  • dynamic-links: include GoogleUtilities pod (2bbfe51), closes #104
  • messaging: remove POST_NOTIFICATIONS for older api (48397a5)

2.2.0-alpha.1 (2022-07-20)

Bug Fixes

  • messaging-core: AuthorizationStatus enum export (#101) (fa4b6bd)

2.2.0-alpha (2022-07-20)

Bug Fixes

  • messaging: use new requestPermission & permission check for API 33+ (d1328ef)

Features

  • support external push provider (a53d5a9), closes #7

2.1.0 (2022-06-07)

Bug Fixes

  • messaging: TNSFirebaseMessaging is not defined (e66a54d)

Features

  • auth: add getProviderCredential (7af0baf)

2.0.2 (2022-05-29)

Bug Fixes

  • admob: remove deleted method (f0ccb4a)
  • functions: remove deleted method (35c3f44)

2.0.1 (2022-05-19)

Bug Fixes

2.0.0 (2022-05-18)

Bug Fixes

  • admob: declare as static (44f66b9)
  • admob: update input (dcb2b07)
  • auth: currentUser is nullable (#82) (8f5cab1)
  • dynamic-links: prevent crash when annotation is null (#86) (8a53b8b)
  • HttpsCallableResult type (#81) (b6e431b)
  • messaging: prevent loss of messages when app is closed. (#84) (f75d682)
  • TypeError onComplete is not a function (#80) (e575475)
  • appcheck: declare as static (#88) (4dc8122)
  • messaging: declare as static (#77) (4dc8122)

Features

1.2.2 (2022-04-02)

Bug Fixes

  • dynamiclinks: improve onLink handling (9d3fb8c)

1.2.1 (2022-04-01)

Bug Fixes

  • auth: move ios instance setu (57d6c3e)
  • auth: sendEmailVerification crash (335222d)
  • messaging: replace simulator check (70862a8)

Features

1.2.0 (2022-03-21)

Bug Fixes

  • firestore: android write batch (5a3b2a9)
  • firestore: ios date serialization (0182618)

1.1.5 (2022-03-21)

Bug Fixes

  • auth: return currentUser directly from the native instance (#69) (e368012)

1.1.4 (2022-03-16)

Bug Fixes

  • use (anonymous) for empty functionNames when generating stack information (#66) (8e2d1f0), closes #65

Features

  • nx migrate @nativescript/plugin-tools (d081a2d)