GeoSpark provides an Cordova plugin that enables App developers to track location, geofence and trips.

Step 1: Install the plugin

In your project directory, install from npm, and then add it

$ npm i cordova-plugin-geospark
$ cordova plugin add cordova-plugin-geospark

Step 2: Install SDK


Configure Project

To configure the location services, add following entries to the Info.plist file.

pod 'GeoSpark'

Then, in your project settings, go to Capabilities > Background Modes and turn on background fetch, location updates, remote-notifications.

Then, go to Build Settings in the project targets and change Always Embed Swift Standard Libraries to Yes.

Step 3: Initialize SDK


///In GeoSparkPlugin class include the code below.
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
GeoSpark.initialize( this.cordova.getActivity().getApplication(), "PUBLISHABLEKEY");


Import GeoSpark into your AppDelegate file.

import GeoSpark

Initialize the SDK in your AppDelegate class before calling any other GeoSpark methods under this application:didFinishLaunchingWithOptions:

func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true

Step 4. Create a user

GeoSpark SDK needs a User ID object to identify the device.

cordova.plugins.geospark.createUser("Description", function(success){
// do something on success
}, function(error){
// do something on error

Step 5: Get permissions

Get location permission from the App user on the device. Also check if the user has turned on location services for the device. In addition, get motion permission for iOS.

// Call this method to check Location Permission for Android & iOS
// do something with status
// Call this method to request Location Permission for Android & iOS
// do something with status


// Call this method to check Motion Permission for iOS
// do something with status
// Call this method to request Motion Permission for iOS
// do something with status


// Call this method to check Location services for Android
// do something with status
// Call this method to request Location services for Android
// do something with status

Step 6. Start Location tracking

To start tracking the location.