Swift 3 Notice:
I have a branch running succesfully with the new changes for Swift 3 and Xcode. https://github.com/pmwisdom/cordova-background-geolocation-services/tree/swift3_2
The more testing it gets the sooner I'll release it.
What is this?
This plugin is for enabling background geolocation in your cordova project. It was aimed with the specific goal of normalizing the API for android and iOS and retrieving constant location updates in the background until you tell it to stop (If you tell it you want updates every 3 seconds it will give you one every 3 seconds). This is currently in active development. Feel free to make any requests.
I've also included an activity detection API. It is used to save battery life, but you can also retrieve the likelihood of what the user is currently doing (standing still, walking, running, driving, etc).
- 1.1.0 -Breaking- (If you need the lower swift versions, use 1.0.4)
- 1.0.4 New Low GPS mode for increased battery life on iOS
- 1.0.3 Activity Detection And Much Better Battery Life For iOS!
- 1.0.2 Error callbacks now correctly funnel through the location register
Android : Uses Fused Location API and Activity Recognition API to serve location updates endlessly.
iOS : Uses a timer based approach and CoreMotion library to enable endless background tracking.
- Make sure you have Google Play Services AND Google Repository installed via your android-sdk manager prior to building your application with this. It will be under the extras part of the sdk manager. More information can be found here: http://developer.android.com/sdk/installing/adding-packages.html.
cordova plugin add https://github.com/pmwisdom/cordova-background-geolocation-services.git --save
meteor add mirrorcell:background-geolocation-plus
How to use:
This plugin exports an object at
//Make sure to get at least one GPS coordinate in the foreground before starting background servicesnavigatorgeolocation;//Get pluginvar bgLocationServices = windowpluginsbackgroundLocationServices;//Congfigure PluginbgLocationServices;//Register a callback for location updates, this is where location objects will be sent in the backgroundbgLocationServices;//Register for Activity Updates//Uses the Detected Activies / CoreMotion API to send back an array of activities and their confidence levels//See here for more information://bgLocationServices;//Start the Background Tracker. When you enter the background tracking will start, and stop when you enter the foreground.bgLocationServicesstart;///later, to stopbgLocationServices;
Phonegap Build : Swift files are not officially supported as of yet on phonegap build, so if there is a problem installing it in that environment, there isn't anything I can do until they are supported.