{"id":13800860,"url":"https://github.com/transistorsoft/capacitor-background-geolocation-firebase","last_synced_at":"2025-08-10T04:07:11.584Z","repository":{"id":47077249,"uuid":"387517583","full_name":"transistorsoft/capacitor-background-geolocation-firebase","owner":"transistorsoft","description":"Firebase adapter for Capacitor Background Geolocation","archived":false,"fork":false,"pushed_at":"2024-11-05T16:03:43.000Z","size":1126,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-08T23:27:21.655Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/transistorsoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-19T15:50:10.000Z","updated_at":"2024-11-05T16:03:39.000Z","dependencies_parsed_at":"2024-11-24T11:07:08.155Z","dependency_job_id":"28e28c6f-d736-4de0-b0d1-7825d94180f9","html_url":"https://github.com/transistorsoft/capacitor-background-geolocation-firebase","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"b7efd6534ed0a8f06c956a13a9a4b32d4bd3b0b1"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/transistorsoft/capacitor-background-geolocation-firebase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fcapacitor-background-geolocation-firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fcapacitor-background-geolocation-firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fcapacitor-background-geolocation-firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fcapacitor-background-geolocation-firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/transistorsoft","download_url":"https://codeload.github.com/transistorsoft/capacitor-background-geolocation-firebase/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fcapacitor-background-geolocation-firebase/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269668046,"owners_count":24456488,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2024-08-04T00:01:17.034Z","updated_at":"2025-08-10T04:07:11.534Z","avatar_url":"https://github.com/transistorsoft.png","language":"TypeScript","funding_links":[],"categories":["[Transistor Software plugins](https://www.transistorsoft.com//)"],"sub_categories":["Specialized Hardware"],"readme":"# capacitor-background-geolocation-firebase\n\n[![](https://dl.dropboxusercontent.com/s/nm4s5ltlug63vv8/logo-150-print.png?dl=1)](https://www.transistorsoft.com)\n\nBy [**Transistor Software**](http://transistorsoft.com), creators of [**Capacitor Background Geolocation**](http://www.transistorsoft.com/shop/products/capacitor-background-geolocation)\n\n------------------------------------------------------------------------------\n\nFirebase Proxy for [Capacitor Background Geolocation](https://github.com/transistorsoft/capacitor-background-geolocation).  The plugin will automatically post locations to your own Firebase database, overriding the `capacitor-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## :large_blue_diamond: Installing the Plugin\n\n### From npm\n\n```\n$ npm install @transistorsoft/capacitor-background-geolocation-firebase --save\n```\n\n### From yarn\n\n```bash\n$ yarn add @transistorsoft/capacitor-background-geolocation-firebase\n```\n\n### Latest from Github\n\n```\n$ npm install git+https://git@github.com:transistorsoft/capacitor-background-geolocation-firebase.git --save\n```\n\n## :large_blue_diamond: Setup Guides\n\n## iOS\n\n- [Required Setup](help/INSTALL-IOS.md)\n\n## Android\n\n- [Required Setup](help/INSTALL-ANDROID.md)\n\n## :large_blue_diamond: Configure your license\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 to `android/app/src/main/AndroidManifest.xml`:\n\n```diff\n\u003cmanifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.your.app\"\u003e\n\n  \u003capplication\n    android:name=\".MainApplication\"\n    android:allowBackup=\"true\"\n    android:label=\"@string/app_name\"\n    android:icon=\"@mipmap/ic_launcher\"\n    android:theme=\"@style/AppTheme\"\u003e\n\n    \u003c!-- capacitor-background-geolocation-firebase licence --\u003e\n+     \u003cmeta-data android:name=\"com.transistorsoft.firebaseproxy.license\" android:value=\"YOUR_LICENCE_KEY_HERE\" /\u003e\n    .\n    .\n    .\n  \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\n## :large_blue_diamond: Using the plugin ##\n\n```javascript\nimport {BackgroundGeolocationFirebase} from \"capacitor-background-geolocation-firebase\";\n```\n\n## :large_blue_diamond: Example\n\n```javascript\n\nimport { Component } from '@angular/core';\n\nimport BackgroundGeolocation from '@transistorsoft/capacitor-background-geolocation';\nimport {BackgroundGeolocationFirebase} from '@transistorsoft/capacitor-background-geolocation-firebase';\n\n@Component({\n  selector: 'app-home',\n  templateUrl: 'home.page.html',\n  styleUrls: ['home.page.scss'],\n})\nexport class HomePage {\n  constructor() {}\n\n  // Initialize in ngAfterContentInit\n  // [WARNING] DO NOT use ionViewWillEnter, as that method won't run when app is launched in background.\n  ngAfterContentInit() {\n    this.initBackgroundGeolocation();\n  }\n\n  async initBackgroundGeolocation() {\n    ////\n    // 1. configure BackgroundGeolocationFirebase\n    //\n    BackgroundGeolocationFirebase.configure({\n      locationsCollection: \"locations\",\n      geofencesCollection: \"geofences\"\n    });\n\n    ////\n    // 2.  Configure BackgroundGeolocation as usual.\n    //\n    BackgroundGeolocation.ready({\n      ...\n    }.then((state) =\u003e {\n      console.log(\"- BackgroundGeolocation is configured and ready\");\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  geofencesCollection: '/users/123/geofences'\n});\n\nBackgroundGeolocationFirebase.configure({\n  geofencesCollection: '/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) 2021 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%2Fcapacitor-background-geolocation-firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftransistorsoft%2Fcapacitor-background-geolocation-firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftransistorsoft%2Fcapacitor-background-geolocation-firebase/lists"}