[New Feature] Background Geolocation "Headless Mode" for Android Posted on 04 Feb 16:25 , 0 comments

On Android, when you terminate your app with the BackgroundGeolocation plugin configured with stopOnTerminate: false, your Javascript code is completely terminated -- only the plugin's native Android background service continues running.  If you've configured the plugin with an #url, its Android background Service will continue posting locations to your server.

But what if you need to implement some custom business logic in the "headless" state, such as posting a local notification or executing #getCurrentPosition in a heartbeat event?

The BackgroundGeolocation plugin for React Native and Cordova now provides a mechanism for you to implement your own custom code to handle all the plugin's events while in the "Headless" state (heartbeat, location, motionchange, geofence, etc).

React Native

For React Native users, you get the best implementation because the plugin implements the React Native Headless JS mechanism.  This allows you to implement your "Headless Task" in the Javascript environment.  No native Android code required for you!

Try it out

With your React Native debugger connected, terminate your app and observe log messages arriving from your HeadlessTask.

For more information, see the React Native Background Geolocation Wiki Android Headless Mode.

Cordova / Ionic

For Cordova users, unfortunately the Cordova platform provides no such mechanism to execute Javascript code in the Headless state, so you'll have to implement your Headless code in the native Android environment with Java code.  Don't be daunted -- it's really not that difficult.

Step 1

First, create a Java file named in your src folder (eg: src/android/ This file must extend HeadlessTask and implement HeadlessTask.Receiver exactly as shown below:

Step 2

Next, you need to instruct Cordova to copy your custom source-file file into the background-geolocation plugin's src-tree. In your Cordova config.xml, add the following element to copy your custom source-file:

Step 3

Finally, configure the plugin with enableHeadless: true:

Try it out

While observing $ adb logcat, terminate your app and observe log messages arriving from your custom BackgroundGeolocationHeadlessTask.  With just a small handful of Java code, you're now receiving all events emitted by the plugin while in the Headless state with your app terminated.

The entire BackgroundGeolocation API is available to you in the native environment -- anything you can do in Javascript, you can do in  the native environment.  In fact, the entire Android API universe is available to you.  If you have any experience with native Android development, this won't be a difficult task for you.  If you have no experience with Java, we can assist in writing your own custom tasks in a couple of hours.

For more information, see the Cordova Background Geolocation Wiki Android Headless Mode.

Background Geolocation Console Posted on 19 Dec 10:01 , 0 comments

A great way to field-test the background-geolocation plugin is to use our test-server which we provide open-source at Github background-geolocation-console.  It's a simple node-server and web-application for quickly viewing your device tracking.  It's very easy to setup and configure the background-geolocation plugin to post to it.

The Background Geolocation sample-apps (Cordova, React Native) are already pre-configured to post to a hosted version of the tracking console at

The background geolocation console is particularly useful for geofence-testing.  Geofence transitions are marked by coloured dot on the geofence edge (red = exit, green = entry, yellow=dwell) with a black polyline pointing to the triggering location.

If you want to post to the tracking console in your own app, it's very easy:  simply provide some device information in the plugin's #params config:

After booting your app to record some locations, visit the tracking console in your browser at

Android Oreo (version 8) Posted on 19 Dec 09:03 , 0 comments

Yes, in spite of Android Oreo's strict new Background Execution Limits, the Background Geolocation plugin fully supports Android 8.  The caveat however, is that the foregroundService: true option is now enforced.

When To Go Native Over Javascript Posted on 12 Jun 21:54 , 0 comments

Here's a nice little presentation by Harry Tormey at React Chicago which clearly lays out the complexities involved with tracking a device's location in the background and why this needs to be done directly with Native APIs.

This is exactly what the Background Geolocation plugin does for you.

(Watch for his recommendation to use Transistor Software's react-native-background-geolocation plugin at 19:42, thanks Harry ;)

New Feature: HTTP JSON Templates Posted on 03 Mar 13:39 , 0 comments

Traditionally, the BackgroundGeolocation plugin has had a hard-coded "Location Data Schema" which you've had to modify your server to consume:

No longer. Now you can finally configure your own templates with the plugin to customize your own HTTP JSON schema:

The following template tags are currently supported:

See the "HTTP Features" docs for your desired platform:

Ionic 2 and Cordova Background Geolocation Posted on 09 Feb 15:51 , 0 comments

Yes, the cordova-background-geolocation plugin works fine with Ionic 2.  I really don't see a great need for a definitions file.  The Demo App is now built with Ionic 2.

Here's a simple Ionic 2 implementation:

Infinite Geofencing Posted on 04 Jan 15:27 , 0 comments

BackgroundGeolocation now supports infinite geofencing.  Why is this important?  Because the native platforms limit the number of geofences which can be simultaneously monitored.  For iOS the limit is 20 while Android allows 100.

Previously, you had to manually manage which geofences to monitor based upon the current location, perhaps asking the server periodically which geofences were within range.

Now you can load any number of geofences into the plugin (tested with tens-of-thousands).  The plugin will periodically perform a geospatial query upon the geofences in the database, activating those closest within a configurable geofenceProximityRadius.

Following is an animation of this feature performed in the iOS simulator, where a series of geofences have been loaded along the entire City Drive route.

With Infinite Geofencing, BackgroundGeolocation is the most advanced geofencing plugin available, more advanced than any dedicated geofencing plugin.

New BackgroundGeolocation feature: #watchPosition Posted on 22 Sep 17:40 , 0 comments

BackgroundGeolocation now has its own native #watchPosition method!

#watchPosition will keep your app running in the background (even on iOS!), so be careful with it.

Tracking Iceland Posted on 29 Jun 09:01 , 0 comments

During June 12-27 2016, I took a vacation in Iceland, circumnavigating the entire island.  This was a great opportunity to do a long-term field-test in a remote, mountainous and sparsely populated territory.

I used two phones:  iPhone 6s @ 9.3.2 and Android Nexus 5 @ 6.0.1 running Cordova Background Geolocation 1.7.0.

The results were much better than expected, even while travelling up rugged mountain roads and remote gravel-roads.

See the results with browsable map here

Cordova Background Geolocation 

React Native Background Geolocation

Native Script Background Geolocation

Background Geolocation Scheduler Posted on 22 Apr 00:18 , 0 comments

I've added new Scheduler feature for Background Geolocation.  It's working pretty fine with Android & iOS so far.

The Scheduler is able to auto-start itself on boot and have similar #stopOnTerminate option as well as #forceReload to auto-start the foreground activity (where your Javascript lives).