{"id":13798878,"url":"https://github.com/EddyVerbruggen/nativescript-plugin-firebase","last_synced_at":"2025-05-13T06:32:02.615Z","repository":{"id":2563086,"uuid":"46665106","full_name":"EddyVerbruggen/nativescript-plugin-firebase","owner":"EddyVerbruggen","description":":fire: NativeScript plugin for Firebase","archived":true,"fork":false,"pushed_at":"2023-04-04T07:50:03.000Z","size":50859,"stargazers_count":1009,"open_issues_count":593,"forks_count":439,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-05-12T21:13:57.173Z","etag":null,"topics":["admob","analytics","authentication","crashlytics","facebook","fcm","firebase","firestore","google","in-app-messaging","invites","machine-learning","mlkit","nativescript","pushnotifications","realtime-database","storage","tensorflow"],"latest_commit_sha":null,"homepage":"https://firebase.google.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EddyVerbruggen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-11-22T14:54:52.000Z","updated_at":"2025-04-28T01:18:04.000Z","dependencies_parsed_at":"2023-07-06T11:31:57.916Z","dependency_job_id":null,"html_url":"https://github.com/EddyVerbruggen/nativescript-plugin-firebase","commit_stats":{"total_commits":1478,"total_committers":136,"mean_commits":"10.867647058823529","dds":0.2943166441136671,"last_synced_commit":"9cf63ff4aa9feb416ca814d77bd241292ec6bb2d"},"previous_names":[],"tags_count":147,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-plugin-firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-plugin-firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-plugin-firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-plugin-firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EddyVerbruggen","download_url":"https://codeload.github.com/EddyVerbruggen/nativescript-plugin-firebase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253889036,"owners_count":21979556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["admob","analytics","authentication","crashlytics","facebook","fcm","firebase","firestore","google","in-app-messaging","invites","machine-learning","mlkit","nativescript","pushnotifications","realtime-database","storage","tensorflow"],"created_at":"2024-08-04T00:00:55.965Z","updated_at":"2025-05-13T06:31:57.593Z","avatar_url":"https://github.com/EddyVerbruggen.png","language":"TypeScript","funding_links":[],"categories":["모바일","Awesome {N} [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)"],"sub_categories":["Table of Contents"],"readme":"# NativeScript Firebase plugin\n\n\u003cimg src=\"docs/images/firebase-logo.png\" width=\"116px\" height=\"32px\" alt=\"Firebase\"/\u003e\u003cbr/\u003e\n\n[![NPM version][npm-image]][npm-url]\n[![Downloads][downloads-image]][npm-url]\n[![TotalDownloads][total-downloads-image]][npm-url]\n\n[npm-image]:https://img.shields.io/npm/v/@nativescript/firebase.svg\n[npm-url]:https://npmjs.org/package/@nativescript/firebase\n[downloads-image]:https://img.shields.io/npm/dm/@nativescript/firebase.svg\n[total-downloads-image]:https://img.shields.io/npm/dt/@nativescript/firebase.svg?label=total%20downloads\n\n\u003e 🚨🚨🚨 I'M NO LONGER ABLE TO MAINTAIN THIS PROJECT - I'm archiving the project for now, but if you want to take over, please don't open an issue, but hit me up on Twitter @eddyverbruggen. Alternatively, please check out this excellent plugin: https://github.com/NativeScript/firebase\n\n## Features\n* [AdMob](docs/ADMOB.md)\n* [Analytics](docs/ANALYTICS.md)\n* [Authentication](docs/AUTHENTICATION.md)\n* [Cloud Firestore](docs/FIRESTORE.md)\n* [Cloud Functions](docs/FUNCTIONS.md)\n* [Cloud Messaging](docs/MESSAGING.md) / [Non-Firebase Push Messaging](docs/NON_FIREBASE_MESSAGING.md)\n* [Crashlytics](docs/CRASHLYTICS.md)\n* [In-App Messaging](docs/IN_APP_MESSAGING.md)\n* [Dynamic Links](docs/DYNAMIC_LINKS.md)\n* [ML Kit](docs/ML_KIT.md)\n* [Performance Monitoring](docs/PERFORMANCE_MONITORING.md)\n* [Realtime Database](docs/DATABASE.md)\n* [Remote Config](docs/REMOTECONFIG.md)\n* [Storage](docs/STORAGE.md)\n\n## Prerequisites\nHead on over to [https://console.firebase.google.com/](https://console.firebase.google.com/) and sign up for a free account.\nYour first 'Firebase' will be automatically created and made available via an URL like `https://n-plugin-test.firebaseio.com`.\n\nOpen your Firebase project at the Google console and click 'Add app' to add an iOS and / or Android app. Follow the steps (make sure the bundle id is the same as your `nativescript.id` in `package.json` and you'll be able to download:\n\n* iOS: `GoogleService-Info.plist` which you'll add to your NativeScript project at `app/App_Resources/iOS/GoogleService-Info.plist`\n\n* Android: `google-services.json` which you'll add to your NativeScript project at `app/App_Resources/Android/google-services.json`\n\nNote: for using separate versions of these files for development and production environments see [this section](#separation-of-environments)\n\n## Installation\nIf you rather watch a (slightly outdated) video explaining the steps then check out this step-by-step guide - you'll also learn how to\nadd iOS and Android support to the Firebase console and how to integrate anonymous authentication:\n[![YouTube demo](docs/images/yt-thumb-setup.png)](https://youtu.be/IextEpoIzwE \"YouTube demo\")\n\nFrom the command prompt go to your app's root folder and execute this for NativeScript 7+:\n\n```bash\ntns plugin add @nativescript/firebase\n```\n\nor for NativeScript 6:\n\n```bash\ntns plugin add nativescript-plugin-firebase\n```\n\nThis will launch an install script which will guide you through installing additional components.\nCheck the doc links above to see what's what. You can always change your choices later.\n\n\u003e Want to use this plugin with an *external push notification provider* and **not** use any Firebase feature? Just answer 'y' to the first question to skip most of them, and️ [hop on over to the Push Notification](docs/NON_FIREBASE_MESSAGING.md). Do not run the plugin's `.init` function in this case!\n\n\u003e Using [NativeScript SideKick](https://www.nativescript.org/nativescript-sidekick)? Then the aforementioned install script\nwill not (be able to) run. In that case, running the app for Android will result in [this issue](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/829#issuecomment-409870671).\nTo fix that, see [this comment](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/829#issuecomment-409855611).\n\n### Config\nIf you choose to save your config during the installation, the supported options may be saved in the `firebase.nativescript.json` at the root of your app.\nThis is to ensure your app may roundtrip source control and installation on CI won't prompt for user input during installation.\n\nYou can reconfigure the plugin by going to the `node_modules/nativescript-plugin-firebase` and running `npm run config`.\n\nYou can also change the configuration by deleting the `firebase.nativescript.json` and reinstalling the plugin.\n\n\u003e Be advised. Enabling some features (such as [Admob](docs/ADMOB.md)) in the `firebase.nativescript.json` may require additional configuration. If you are experiencing crashes or bugs after installing this plugin please consult the [documentation](docs) for each of the features you've enabled to ensure that no additioal configuration is required.\n\n#### Using Vue?\nPlease update your [NativeScript-Vue](https://github.com/nativescript-vue/vue-cli-template) template to 2.0 because it\naligns perfectly with this plugin (because that template is now much more similar to a regular NativeScript project).\n\nIf you want a demo using Vue and Firestore, then [check out this project](https://github.com/EddyVerbruggen/footplr),\nif you want one with Realtime DB, [check out this one](https://github.com/jlooper/mixology-mobile).\n\n### iOS (Cocoapods)\nThe Firebase iOS SDK is installed via Cocoapods, so run `pod repo update` from the command prompt (in any folder) to ensure you have the latest spec.\n\n#### Google Play Services Version\nThe plugin will default to [this version](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/master/src/platforms/android/include.gradle#L27) of the Android `play-services-base` SDK.\nIf you need to change the version (to for instance the latest version), you can add a project ext property `googlePlayServicesVersion` to `app/App_Resources/Android/app.gradle`:\n\n```\nproject.ext {\n    googlePlayServicesVersion = \"+\"\n}\n```\n\n## Usage\n\n### Demo app\nIf you want a quickstart, clone the repo, then:\n- `cd src`.\n- `npm i` (just answer 'n' to any prompts as they are ignored anyway).\n- `npm run demo.ios` or `npm run demo.android` (answer 'n' again if prompted).\n\n### Start-up wiring\nWe need to do some wiring when your app starts, so open `app.js` and add this before `application.start();`:\n\n##### JavaScript\n```js\n// NativeScript 7+\nvar firebase = require(\"@nativescript/firebase\").firebase;\n\n// NativeScript 6-\nvar firebase = require(\"nativescript-plugin-firebase\");\n\nfirebase.init({\n  // Optionally pass in properties for database, authentication and cloud messaging,\n  // see their respective docs.\n}).then(\n    function () {\n      console.log(\"firebase.init done\");\n    },\n    function (error) {\n      console.log(\"firebase.init error: \" + error);\n    }\n);\n```\n\n#### TypeScript\n```js\n// NativeScript 7+\nimport { firebase } from \"@nativescript/firebase\";\n\n// NativeScript 6-\nconst firebase = require(\"nativescript-plugin-firebase\");\n\nfirebase.init({\n  // Optionally pass in properties for database, authentication and cloud messaging,\n  // see their respective docs.\n}).then(\n  () =\u003e {\n    console.log(\"firebase.init done\");\n  },\n  error =\u003e {\n    console.log(`firebase.init error: ${error}`);\n  }\n);\n```\n\n#### Angular\nBecause of the specifics of the angular bootstrap it is best to initalize firebase once the angular application is running. For example your main compoment's `ngOnInit` method:\n```js\n// NativeScript 7+\nimport { firebase } from \"@nativescript/firebase\";\n\n// NativeScript 6-\nconst firebase = require(\"nativescript-plugin-firebase\");\n\n@Component({\n    // ...\n})\nexport class AppComponent implements OnInit {\n  ngOnInit() {\n    firebase.init({\n      // Optionally pass in properties for database, authentication and cloud messaging,\n      // see their respective docs.\n    }).then(\n      () =\u003e {\n        console.log(\"firebase.init done\");\n      },\n      error =\u003e {\n        console.log(`firebase.init error: ${error}`);\n      }\n    );\n  }\n}\n```\n\n## Known issues on iOS\n\n#### Trouble running on the simulator\nOpen or create `App_Resources/iOS/\u003cappname\u003e.entitlements` and add these two keys with the value `true`:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\u003e\n\u003cplist version=\"1.0\"\u003e\n\u003cdict\u003e\n    \u003ckey\u003ecom.apple.keystore.access-keychain-keys\u003c/key\u003e\n    \u003ctrue/\u003e\n    \u003ckey\u003ecom.apple.keystore.device\u003c/key\u003e\n    \u003ctrue/\u003e\n\u003c/dict\u003e\n\u003c/plist\u003e\n```\n\n#### Authentication failed: invalid_token\nOn the simulator you may see this message if you have more than one app with the Firebase SDK ever installed:\n\n```\n[FirebaseDatabase] Authentication failed: invalid_token (Invalid claim 'aud' in auth token.)\nor\n[FirebaseDatabase] Authentication failed: invalid_token (audience was project 'firegroceries-904d0' but should have been project 'your-firebase-project')\n```\n\nThis is [a known issue in the Firebase SDK](http://stackoverflow.com/questions/37857131/swift-firebase-database-invalid-token-error).\nI always use a real device to avoid this problem, but you can pass an 'iOSEmulatorFlush' option to init.\n```\nfirebase.init({\n  // Optionally pass in properties for database, authentication and cloud messaging,\n  // see their respective docs and 'iOSEmulatorFlush' to flush token before init.\n  iOSEmulatorFlush: true\n}).then()\n```\n\n#### Pod dependency error\nIf you see an error like `Unable to satisfy the following requirements: Firebase (~\u003e 3.17.0) required by Podfile`,\nthen run `pod repo update` on the command line to make sure you have the latest Podspec.\n\nThis could happen when updating the plugin to a new version. You'll want to `tns platform remove ios \u0026\u0026 tns platform add ios` as well to clean out the old pod version.\n\n## Known issues on Android\n\n#### Genymotion\nYou can use the awesome [Genymotion emulator](https://www.genymotion.com/)\nbut you'll need to [install Google Play Services on it](https://inthecheesefactory.com/blog/how-to-install-google-services-on-genymotion/en) or you'll run into errors during authentication.\n\n#### DexIndexOverflowException\n```\ncom.android.dex.DexIndexOverflowException: method ID not in..\n```\n\nCongrats, you ran into [this issue](https://github.com/NativeScript/android-runtime/issues/344)\nwhich can be solved by adding `multiDexEnabled true` to your `app/App_Resources/Android/app.gradle`\nso it becomes something like this:\n\n```\nandroid {  \n  defaultConfig {  \n    applicationId = \"__PACKAGE__\"  \n    multiDexEnabled true\n    generatedDensities = []\n  }  \n  aaptOptions {  \n    additionalParameters \"--no-version-vectors\"  \n  }  \n}\n```\n\n#### java.lang.OutOfMemoryError: GC overhead limit exceeded\n\nIncrease the Java Max Heap Size like this (the bit at the end):\n\n```\nandroid {  \n  defaultConfig {  \n    applicationId = \"__PACKAGE__\"  \n    multiDexEnabled true\n    generatedDensities = []\n  }\n  aaptOptions {  \n    additionalParameters \"--no-version-vectors\"  \n  }\n  dexOptions {\n    javaMaxHeapSize \"4g\"\n  }\n}\n```\n\n#### FirebaseApp with name [DEFAULT] doesn't exist\nAnother possible error is \"FirebaseApp with name [DEFAULT] doesn't exist.\" which will be solved by\nplacing `google-services.json` to `platforms/android/google-services.json` (see above), and making\nthe changes to `build.gradle` which are mentioned above as well.\n\n#### Errors regarding API level 26.0.0\nUpdate your local Android SDKs:\n\nJust run `$ANDROID_HOME/tools/bin/sdkmanager --update` from a command prompt\nor launch the SDK manager from Android Studio, expand `Extras` and install any pending updates.\n\n#### Found play-services:A.C.D, but version B.X.Y is needed..\nUpdate your Android bits like the issue above and reinstall the android platform in your project.\n\n#### `include.gradle`: Failed to apply plugin .. For input string: \"+\"\nYou probably have another plugin depending on Google Play Services (Google Maps, perhaps).\nWe need to pin to a specific play services version to play nice with others, so open `app/App_Resources/Android/app.gradle` and add:\n\n```js\nandroid {  \n  // other stuff here\n\n  project.ext {\n    googlePlayServicesVersion = \"15.0.0\"\n  }\n}\n```\n\nWhere `\"15.0.0\"` is best set to the same value as the `googlePlayServicesVersion` value in [this file](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/48a99ccd2a0f590c37080b1a252173ea9b996e9f/publish/scripts/installer.js#L540).\n\n## Separation of Environments\n\nIt is possible to use different development and production environments by using multiple `GoogleService-Info.plist` and `google-services.json` files.\n\n### Setup\n1. Create two separate Firebase projects (e.g. `myproject` and `myproject-dev`) and configure them with the same package name\n2. Download the `plist` and `json` files for both projects and put them in the relevant directories with either `.dev` or `.prod` appended to the file names, so you have the following files in place:\n\n    * iOS\n       * `app/App_Resources/iOS/GoogleService-Info.plist.dev`\n       * `app/App_Resources/iOS/GoogleService-Info.plist.prod`\n    * Android\n       * `app/App_Resources/Android/google-services.json.dev`\n       * `app/App_Resources/Android/google-services.json.prod`\n\nNote: if you currently have the `storageBucket` property in the `firebase.init()` then remove it (not mandatory anymore as of version `6.5.0` of this plugin), so it will be taken automatically from the relevant google services `plist` and `json` files.\n\n### Build\nThe build hooks of this plugin will now choose either the `dev` or the `prod` version of your google services `plist` and `json` files depending on how you run your build:\n\n* `dev` will be selected if you run with either `--env.dev`, `--env.development` or `--env.staging` flags.\n* `prod` will be selected if you run with either `--env.prod` or `--env.production`.\n\nNote: Using the `--release` flag without any of the above flags will set the default environment to production. If you need to create a release with dev environment you'll need to set it explicitly.\n\nNote: if you do not have both `dev` and `prod` files in place, the regular `GoogleService-Info.plist` and `google-services.json` files will be used.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEddyVerbruggen%2Fnativescript-plugin-firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEddyVerbruggen%2Fnativescript-plugin-firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEddyVerbruggen%2Fnativescript-plugin-firebase/lists"}