{"id":28539813,"url":"https://github.com/transistorsoft/cordova-background-geolocation-firebase","last_synced_at":"2025-07-08T10:30:54.693Z","repository":{"id":57207452,"uuid":"144997841","full_name":"transistorsoft/cordova-background-geolocation-firebase","owner":"transistorsoft","description":"Firebase Adapter for Cordova Background Geolocation","archived":false,"fork":false,"pushed_at":"2020-11-02T14:52:25.000Z","size":91,"stargazers_count":7,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-30T16:00:05.773Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","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/transistorsoft.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}},"created_at":"2018-08-16T14:17:42.000Z","updated_at":"2021-04-27T08:11:27.000Z","dependencies_parsed_at":"2022-09-08T14:22:35.439Z","dependency_job_id":null,"html_url":"https://github.com/transistorsoft/cordova-background-geolocation-firebase","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/transistorsoft/cordova-background-geolocation-firebase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fcordova-background-geolocation-firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fcordova-background-geolocation-firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fcordova-background-geolocation-firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fcordova-background-geolocation-firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/transistorsoft","download_url":"https://codeload.github.com/transistorsoft/cordova-background-geolocation-firebase/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fcordova-background-geolocation-firebase/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264250170,"owners_count":23579477,"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":[],"created_at":"2025-06-09T18:33:26.736Z","updated_at":"2025-07-08T10:30:54.675Z","avatar_url":"https://github.com/transistorsoft.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"cordova-background-geolocation-firebase \u0026middot; [![npm](https://img.shields.io/npm/dm/cordova-background-geolocation-firebase.svg)]() [![npm](https://img.shields.io/npm/v/cordova-background-geolocation-firebase.svg)]()\n============================================================================\n\n[![](https://dl.dropboxusercontent.com/s/nm4s5ltlug63vv8/logo-150-print.png?dl=1)](https://www.transistorsoft.com)\n\n-------------------------------------------------------------------------------\n\nFirebase Proxy for [Cordova Background Geolocation](https://github.com/transistorsoft/cordova-background-geolocation-lt).  The plugin will automatically post locations to your own Firebase database, overriding the `cordova-background-geolocation` plugin's SQLite / HTTP services.\n\n![](https://dl.dropboxusercontent.com/s/2ew8drywpvbdujz/firestore-locations.png?dl=1)\n\n----------------------------------------------------------------------------\n\nThe **[Android module](https://shop.transistorsoft.com/collections/frontpage/products/background-geolocation-firebase)** requires [purchasing a license](https://shop.transistorsoft.com/collections/frontpage/products/background-geolocation-firebase).  However, it *will* work for **DEBUG** builds.  It will **not** work with **RELEASE** builds [without purchasing a license](https://shop.transistorsoft.com/collections/frontpage/products/background-geolocation-firebase).\n\n----------------------------------------------------------------------------\n\n# Contents\n- ### [Configuration Options](#large_blue_diamond-configuration-options)\n- ### [Installing the Plugin](#large_blue_diamond-installing-the-plugin)\n- ### [Setup Guide](#large_blue_diamond-setup-guide)\n- ### [Using the plugin](#large_blue_diamond-using-the-plugin)\n- ### [Example](#large_blue_diamond-example)\n\n## :large_blue_diamond: Installing the Plugin\n\n### From npm\n\n```\n$ cordova plugin add cordova-background-geolocation-firebase --save\n```\n\n## :large_blue_diamond: Setup Guide\n\nYou also need to download **`google-services.json`** on Android and **`GoogleService-Info.plist`** on iOS from **Firebase Console**.  Place them into the cordova project root folder. Then use `\u003cresource-file\u003e` to copy those files into appropriate folders:\n\n```xml\n\u003cplatform name=\"android\"\u003e\n    \u003cresource-file src=\"google-services.json\" target=\"app/google-services.json\" /\u003e\n    ...\n\u003c/platform\u003e\n\u003cplatform name=\"ios\"\u003e\n    \u003cresource-file src=\"GoogleService-Info.plist\" /\u003e\n    ...\n\u003c/platform\u003e\n```\n\n### Android\n\n- Add the following `\u003cpreference\u003e` to your `config.xml`\n\n```xml\n\u003cwidget\u003e\n  .\n  .\n  .\n  \u003cpreference name=\"GradlePluginGoogleServicesEnabled\" value=\"true\" /\u003e\n  \u003cpreference name=\"GradlePluginGoogleServicesVersion\" value=\"4.2.0\" /\u003e\n\n  \u003cplatform name=\"android\"\u003e\n    \u003cpreference name=\"AndroidXEnabled\" value=\"true\" /\u003e\n    .\n    .\n    .\n  \u003c/platform\u003e\n\u003c/widget\u003e\n```\n\n- Add the following plugin to your app (prefix with `ionic` if using Ionic):\n\n```bash\n$ cordova plugin add cordova-plugin-androidx-adapter\n```\n\n### iOS\n\nThis plugin imports iOS `Firebase` dependencies via **Cocoapods**.  If you're unfamiliar with **Cocoapods**, [see here](https://guides.cocoapods.org/using/getting-started.html) to ensure you have it setup on your system.\n\nAfter installing the plugin and adding the iOS platform, you must execute `$ pod install`:\n\n```\n$ cd platforms/ios\n$ pod install\n```\n\n:warning: If you haven't update your pods in a while:\n```\n$ pod update\n```\n\n:warning: There's a cordova build issue I haven't yet been able to figure out:  `cordova build ios` **will no longer work**:\n\n```\n$ cordova build ios\n\n fatal error:\n      'RxLibrary/GRXWriteable.h' file not found\n#import \u003cRxLibrary/GRXWriteable.h\u003e\n        ^~~~~~~~~~~~~~~~~~~~~~~~~~\n1 error generated.\n```\n\nAs a result, you'll have to build your app using XCode from **`YourProject.xcworkspace`** (**not** `YourProject.xcodeproj`).\n\n### Configure your license\n\n:information_source: If you don't *have* a license yet, the plugin is fully functional in `DEBUG` builds so you can try it before [purchasing a license](https://shop.transistorsoft.com/collections/frontpage/products/background-geolocation-firebase).\n\n1. Login to Customer Dashboard to generate an application key:\n[www.transistorsoft.com/shop/customers](http://www.transistorsoft.com/shop/customers)\n![](https://gallery.mailchimp.com/e932ea68a1cb31b9ce2608656/images/b2696718-a77e-4f50-96a8-0b61d8019bac.png)\n\n2. Add your license-key:\n\n```\n$ cordova plugin remove cordova-background-geolocation-firebase\n$ cordova plugin add cordova-background-geolocation-firebase --variable LICENSE=YOUR_KEY_HERE\n```\n\n## :large_blue_diamond: Using the plugin ##\n\nThe plugin creates the object **`window.BackgroundGeolocationFirebase`**.\n\n```javascript\nvar bgGeoFirebase = window.BackgroundGeolocationFirebase;\n```\n\n### Ionic 2+:\n\n```javascript\nlet bgGeoFirebase = (\u003cany\u003ewindow).BackgroundGeolocationFirebase;\n```\n\n## :large_blue_diamond: Example\n\n```javascript\n\nonDeviceReady() {\n  var bgGeoFirebase = window.BackgroundGeolocationFirebase;\n  bgGeoFirebase.configure({\n    locationsCollection: 'locations',\n    geofencesCollection: 'geofences'\n  });\n\n  // Now configure background-geolocation as normal.  Nothing changes here.\n  var bgGeo = window.BackgroundGeolocation;\n  bgGeo.on('location', function(location) {...});\n  bgGeo.ready({\n    .\n    .\n    .\n  }, function(state) {\n    console.log('[BackgroundGeolocation] ready -', state);\n  });\n}\n\n```\n\n### Ionic 2+\n\n```javascript\nimport { Component } from '@angular/core';\nimport { NavController, Platform } from 'ionic-angular';\n\n@Component({\n  selector: 'page-home',\n  templateUrl: 'home.html'\n})\nexport class HomePage {\n\n  constructor(public navCtrl: NavController, public platform: Platform) {\n\n  }\n\n  ionViewDidLoad() {\n    this.platform.ready().then(() =\u003e {\n      this.configureBackgroundGeolocation();\n    });\n  }\n\n  configureBackgroundGeolocation() {\n    let bgGeoFirebase = (\u003cany\u003ewindow).BackgroundGeolocationFirebase;\n\n    bgGeoFirebase.configure({\n      locationsCollection: 'locations',\n      geofencesCollection: 'geofences'\n    });\n\n    let bgGeo = (\u003cany\u003ewindow).BackgroundGeolocation;\n\n    bgGeo.on('location', (location) =\u003e {\n      console.log('[location] - ', location);\n    });\n\n    bgGeo.ready({\n      stopOnTerminate: false,\n      debug: true\n    }, (state) =\u003e {\n      if (!state.enabled) {\n        bgGeo.start();\n      }\n    });\n  }\n}\n\n\n```\n\n## :large_blue_diamond: Firebase Functions\n\n`BackgroundGeolocation` will post its default \"Location Data Schema\" to your Firebase app.\n\n```json\n{\n  \"location\":{},\n  \"param1\": \"param 1\",\n  \"param2\": \"param 2\"\n}\n```\n\nYou should implement your own [Firebase Functions](https://firebase.google.com/docs/functions/) to \"*massage*\" the incoming data in your collection as desired.  For example:\n\n```typescript\nimport * as functions from 'firebase-functions';\n\nexports.createLocation = functions.firestore\n  .document('locations/{locationId}')\n  .onCreate((snap, context) =\u003e {\n    const record = snap.data();\n\n    const location = record.location;\n\n    console.log('[data] - ', record);\n\n    return snap.ref.set({\n      uuid: location.uuid,\n      timestamp: location.timestamp,\n      is_moving: location.is_moving,\n      latitude: location.coords.latitude,\n      longitude: location.coords.longitude,\n      speed: location.coords.speed,\n      heading: location.coords.heading,\n      altitude: location.coords.altitude,\n      event: location.event,\n      battery_is_charging: location.battery.is_charging,\n      battery_level: location.battery.level,\n      activity_type: location.activity.type,\n      activity_confidence: location.activity.confidence,\n      extras: location.extras\n    });\n});\n\n\nexports.createGeofence = functions.firestore\n  .document('geofences/{geofenceId}')\n  .onCreate((snap, context) =\u003e {\n    const record = snap.data();\n\n    const location = record.location;\n\n    console.log('[data] - ', record);\n\n    return snap.ref.set({\n      uuid: location.uuid,\n      identifier: location.geofence.identifier,\n      action: location.geofence.action,\n      timestamp: location.timestamp,\n      latitude: location.coords.latitude,\n      longitude: location.coords.longitude,\n      extras: location.extras,\n    });\n});\n\n```\n\n## :large_blue_diamond: Configuration Options\n\n#### `@param {String} locationsCollection [locations]`\n\nThe collection name to post `location` events to.  Eg:\n\n```javascript\nBackgroundGeolocationFirebase.configure({\n  locationsCollection: '/locations'\n});\n\nBackgroundGeolocationFirebase.configure({\n  locationsCollection: '/users/123/locations'\n});\n\nBackgroundGeolocationFirebase.configure({\n  locationsCollection: '/users/123/routes/456/locations'\n});\n\n```\n\n#### `@param {String} geofencesCollection [geofences]`\n\nThe collection name to post `geofence` events to.  Eg:\n\n```javascript\nBackgroundGeolocationFirebase.configure({\n  geofencesCollection: '/geofences'\n});\n\nBackgroundGeolocationFirebase.configure({\n  locationsCollection: '/users/123/geofences'\n});\n\nBackgroundGeolocationFirebase.configure({\n  locationsCollection: '/users/123/routes/456/geofences'\n});\n\n```\n\n\n#### `@param {Boolean} updateSingleDocument [false]`\n\nIf you prefer, you can instruct the plugin to update a *single document* in Firebase rather than creating a new document for *each* `location` / `geofence`.  In this case, you would presumably implement a *Firebase Function* to deal with updates upon this single document and store the location in some other collection as desired.  If this is your use-case, you'll also need to ensure you configure your `locationsCollection` / `geofencesCollection` accordingly with an even number of \"parts\", taking the form `/collection_name/document_id`, eg:\n\n```javascript\nBackgroundGeolocationFirebase.configure({\n  locationsCollection: '/locations/latest'  // \u003c-- 2 \"parts\":  even\n});\n\n// or\nBackgroundGeolocationFirebase.configure({\n  locationsCollection: '/users/123/routes/456/the_location'  // \u003c-- 4 \"parts\":  even\n});\n\n// Don't use an odd number of \"parts\"\nBackgroundGeolocationFirebase.configure({\n  locationsCollection: '/users/123/latest_location'  // \u003c-- 3 \"parts\": odd!!  No!\n});\n\n```\n\n\n# License\n\nThe MIT License (MIT)\n\nCopyright (c) 2018 Chris Scott, Transistor Software\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftransistorsoft%2Fcordova-background-geolocation-firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftransistorsoft%2Fcordova-background-geolocation-firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftransistorsoft%2Fcordova-background-geolocation-firebase/lists"}