{"id":28539802,"url":"https://github.com/transistorsoft/background-geolocation-firebase","last_synced_at":"2025-10-06T13:50:29.650Z","repository":{"id":136719583,"uuid":"203998193","full_name":"transistorsoft/background-geolocation-firebase","owner":"transistorsoft","description":"Firebase proxy for Background Geolocation SDK (pure native version)","archived":false,"fork":false,"pushed_at":"2019-08-23T20:21:23.000Z","size":106,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-02T15:40:58.928Z","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-08-23T12:53:34.000Z","updated_at":"2019-08-28T20:46:39.000Z","dependencies_parsed_at":"2023-07-03T14:54:23.430Z","dependency_job_id":null,"html_url":"https://github.com/transistorsoft/background-geolocation-firebase","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/transistorsoft/background-geolocation-firebase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fbackground-geolocation-firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fbackground-geolocation-firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fbackground-geolocation-firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fbackground-geolocation-firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/transistorsoft","download_url":"https://codeload.github.com/transistorsoft/background-geolocation-firebase/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transistorsoft%2Fbackground-geolocation-firebase/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278621838,"owners_count":26017253,"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-10-06T02:00:05.630Z","response_time":65,"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":"2025-06-09T18:33:22.017Z","updated_at":"2025-10-06T13:50:29.320Z","avatar_url":"https://github.com/transistorsoft.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"background-geolocation-firebase\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 [BackgroundGeolocation Native SDK](https://github.com/transistorsoft/background-geolocation-lt).  The plugin will automatically post locations to your own Firebase database, overriding the `background-geolocation` SDK'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\nYou will have to install the plugin by manually downloading [a Release](https://github.com/transistorsoft/background-geolocation-firebase/releases) from this repository.  The plugin is not currently submitted to a package manager (eg: jCenter)\n\nCreate a folder in the root of your application project, eg: `/Libraries` and place the extracted **`background-geolocation-firebase`** folder into it:\n\neg: :open_file_folder: **`Libraries/background-geolocation-firebase`**\n\n\n## :large_blue_diamond: Setup Guides\n\n- ### iOS\n    - [Cocoapods Setup](docs/INSTALL-IOS.md)\n- ### Android\n    - [Manual Setup](docs/INSTALL-ANDROID.md)\n\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.transistorsoft.backgroundgeolocation.firebasedemo\"\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!-- 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### iOS\n\n```Obj-c\n#import \"ViewController.h\"\n\n@import TSLocationManager;\n#import \"BackgroundGeolocationFirebase.h\"\n\n@interface ViewController ()\n\n@end\n\n@implementation ViewController\n\n- (void)viewDidLoad {\n\n    TSLocationManager *bgGeo = [TSLocationManager sharedInstance];\n    TSConfig *config = [TSConfig sharedInstance];\n\n    // Get a reference to BackgroundGeolocationFirebase adapter\n    BackgroundGeolocationFirebase *firebaseAdapter = [BackgroundGeolocationFirebase sharedInstance];\n    // Configure firebase adapter as desired.\n    firebaseAdapter.locationsCollection = @\"locations\"; // \u003c-- \"locations\" is default\n    firebaseAdapter.geofencesCollection = @\"geofences\"; // \u003c-- \"geofences\" is default\n    firebaseAdapter.updateSingleDocument = NO;          // \u003c-- NO is default\n    // Register the Firebase adapter with BackgroundGeolocation\n    [config registerPlugin:firebaseAdapter.name];\n\n    // Continue implementing BackgroundGeolocation as normal\n    [config updateWithBlock:^(TSConfigBuilder *builder) {\n        builder.debug = YES;\n        builder.logLevel = tsLogLevelVerbose;\n    }];\n\n    [bgGeo ready];\n\n    [bgGeo start];\n\n    [super viewDidLoad];\n}\n\n@end\n\n```\n\n### Android\n\n```java\npublic class MainActivity extends AppCompatActivity {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        ////\n        // Get a reference to TSFirebaseProxy\n        //\n        TSFirebaseProxy firebaseProxy = TSFirebaseProxy.getInstance(getApplicationContext());\n        // Configure the TSFirebaseProxy\n        firebaseProxy.setLocationsCollection(\"locations\");  // \u003c-- \"locations\" is default\n        firebaseProxy.setGeofencesCollection(\"geofences\");  // \u003c-- \"geofences\" is default\n        firebaseProxy.setUpdateSingleDocument(false);       // \u003c-- false is default.\n        // Register the TSFirebaseProxy\n        firebaseProxy.register(getApplicationContext());\n\n        // Continue implementing BackgroundGeolocation as normal\n        final BackgroundGeolocation bgGeo = BackgroundGeolocation.getInstance(getApplicationContext(), getIntent());\n        final TSConfig config = TSConfig.getInstance(getApplicationContext());\n\n        // Configure the SDK:\n        config.updateWithBuilder()\n                // Configure Debugging\n                .setDebug(true)\n                // Configure Geolocation\n                .setDesiredAccuracy(LocationRequest.PRIORITY_HIGH_ACCURACY)\n                .setDistanceFilter(50f)\n                .commit();\n\n        // Finally, signal #ready to the plugin.\n        bgGeo.ready(new TSCallback() {\n            @Override public void onSuccess() {\n                TSLog.logger.debug(\"[ready] success\");\n                if (!config.getEnabled()) {\n                    bgGeo.start();\n                }\n            }\n            @Override public void onFailure(String error) {\n                TSLog.logger.debug(\"[ready] FAILURE: \" + error);\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\nEg:\n  - `\"/locations\"`\n  - `\"/users/123/locations\"`\n  - `\"/users/123/routes/456/locations\"`\n\n#### `@param {String} geofencesCollection [geofences]`\n\nThe collection name to post `geofence` events to.  Eg:\n\nEg:\n  - `\"/geofences\"`\n  - `\"/users/123/geofences\"`\n  - `\"/users/123/routes/456/geofences\"`\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\nEg:\n- `\"/locations/latest\"                        // \u003c-- 2 \"parts\":  even`\n- `\"/users/123/routes/456/the_location\"       // \u003c-- 4 \"parts\":  even`\n\n:warning: Do **not** use an *odd* number of \"parts\"\n- `\"/users/123/latest_location\"               // \u003c-- 3 \"parts\": odd!!  No!`\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%2Fbackground-geolocation-firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftransistorsoft%2Fbackground-geolocation-firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftransistorsoft%2Fbackground-geolocation-firebase/lists"}