Skip to content



StreetHawk's Location plugin lets you run location based campaigns based on real time location of your application's user. Also the plugin is useful to accurately calculate your user's home and work location so as to target them at their best times to respond to your campaigns. You can find the source code of the plugin here.


  • Add streethawkanalytics plugin
    Locations plugin depends on analytics plugin. Click here to integrate StreetHawk's Analytics plugin if you haven't already done it.

  • Add streethawklocations plugin
    Execute below mentioned command to apply StreetHawk.

$ cordova plugin add streethawklocations

Alternatively you can use plugman to install the plugins by using following commands:

plugman install --platform <android|ios>  --project ./PATH_TO_PROJECT/platform/<android|ios> --plugin streethawklocations

Additional configuration for iOS applications.

  • Modify Info.plist
    Since iOS 8 it needs to modify Info.plist to enable location service.

Delay asking for iOS location permission (iOS only)

Include in streethawklocations plugin, or streethawkgeofence plugin, or

By default StreetHawk library request for location permission as soon as streethawkinit is called. In case you wish to delay this and later ask the user for location permission at an appropriate time, you can add the code be as shown below.

var sh = cordova.require("com.streethawk.core.Streethawk");
sh.shSetDefaultLocationService(false); //make streethawkinit not enable location service, delay for later time.
//do streethawkinit and other things.
sh.shSetLocationEnabled(true);  //later when ready to enable location service, call this.

At any time, you can check whether location is enabled by code:

var sh = cordova.require("com.streethawk.core.Streethawk");
function failCallback(result) {
    alert("Fail: " + result);
var isLocationEnabled;
sh.shGetLocationEnabled(function(result){isLocationEnabled = result;}, failCallback);