Different results between Android and iOS mobile devices when using the cordova-backg

Hi all,

We're currently using the cordova-background-geolocation-services plugin within OutSystems (https://www.outsystems.com/forge/component/1623/background-location-plugin/). So far this is working out well for us, however on Android devices we see different behaviour when compared to iOS devices. On iOS devices intervals are happening every 900 seconds, on several tested Android devices the intervals range between 0 and approx. 400 seconds. Furthermore when an Android device is not being used for a longer period (for example during nighttime) intervals are about 15000 seconds.

I've traced this down to the configure block which takes several parameters ($parameters being the name of global variables being passed to this block of code):

//Configure Plugin
desiredAccuracy: $parameters.desiredAccuracy, // Desired Accuracy of the location updates (lower means more accurate but more battery consumption)
distanceFilter: $parameters.distanceFilter, // (Meters) How far you must move from the last point to trigger a location update
debug: $parameters.debug, // <-- Enable to show visual indications when you receive a background location update
interval: $parameters.interval, // (Milliseconds) Requested Interval in between location updates.
useActivityDetection: $parameters.useActivityDetection, // Uses Activitiy detection to shut off gps when you are still (Greatly enhances Battery Life)

//Android Only
notificationTitle: $parameters.notificationTitle, // customize the title of the notification
notificationText: $parameters.notificationText, //customize the text of the notification
fastestInterval:$parameters.fastestInterval // <-- (Milliseconds) Fastest interval your app / server can handle updates


interval has a value of 900000 / 60000 (= 15 min / 1 min)
useActivityDetection has a value of False (always)
distanceFilter has a value of 5 / 1
fastestInterval has a value of (same as interval)

Some additional information in addition to above:
 - We use the cordova-background-geolocation-services as a plugin in the OutSystems environment
 - We have seen this behaviour on different Android devices using OS 7 or 8.

I'm curious if anyone else has experience on this issue. If above needs to be clarified I'm willing to provide more details. Thanks in advance for any help provided.

Thanks and regards,

Hi Erik,

It's hard to say something as of now. Can you please share sample code so that someone can help?

Hi Suraj,

Thanks for your reply. Above code is taken from the BgLocationServicesConfigure client action which is included in the BackgroundLocationServicesPlugin. In turn, this plugin is used as a dependency in our application.

We use the BgLocationServicesConfigure specifically in one client action called SchedulerEvent. This event:

  • Checks if a MobileDevice identifier (unique code for each mobile device registered in the entity) is available
  • If so, check if the BackgroundLocation plugin is available
  • If it is, stop any running BackgroundLocationServices
  • Next, if a user is being livetracked (user can be found with a GPS coordinate) determine the interval: Default value = 900000ms, livetracking value = 60000ms
  • Next, through the BackgroundLocationServicesRegisterForUpdates client action a callback is registered for location updates, this is where location objects will be sent in the background. Locations retrieved in background are stored in the local entity LocalLocation.
  • If no errors occur, start the BackgroundLocationServices plugin again
  • Update the value for BGLocationServicesConfigure with the following JavaScript block:
    • var timer = setInterval(function(){
      },  $parameters.SecondsInterval * 1000);

Above flow as being used in OutSystems:

If anyone can help it would be appreciated.

Thanks and regards,

Erik van Deursen wrote:

We're currently using the cordova-background-geolocation-services plugin within OutSystems (https://www.outsystems.com/forge/component/1623/background-location-plugin/). 

Correction, we're actually using this: https://github.com/pmwisdom/cordova-background-geolocation-services

It is not a Forge component (yet).


We have discovered setting the DistanceFilter parameter to anything other than 0 will cause the Interval time to be ignored on Android. So the solution, if you want a location update at regular intervals on Android, is to set DistanceFilter = 0.