mobicontrol.location

This namespace provides access to device geographic location management.
Since:

Classes

Geofence

Location

LocationError

Members

static, readonly LocationStatusCode :object

This enumeration represents an error status code of mobicontrol.location.LocationError.
Properties:
Name Type Description
NO_PERMISSION object The agent has none of the necessary location permissions; both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION are missing.
LOCATION_SERVICES_OFF object Location services are turned off.
NOT_SUPPORTED object Location feature is not supported.
UNKNOWN object The exact error could not be determined.
Since:

Methods

static createGeofence(nodes) → {mobicontrol.location.Geofence}

Create a geofence.

See also Location tutorial.

Parameters:
Name Type Description
nodes Array.<mobicontrol.location.Location> The list of nodes forming the geofence.
Returns:
mobicontrol.location.Geofence - A geofence formed by the given nodes.
Since:

static createLocation(latitude, longitude) → {mobicontrol.location.Location}

Create a location.

Parameters:
Name Type Description
latitude number The latitude, must be between -90 and 90.
longitude number The longitude, must be between -180 and 180.
Returns:
mobicontrol.location.Location - A new location with the specified coordinates.
Since:
Example
const LATITUDE = 43.613562;
const LONGITUDE = -79.752868;
var destination = mobicontrol.location.createLocation(LATITUDE, LONGITUDE);
navigate(destination)

function navigate(place) {
    mobicontrol.log.info('Navigating to the destination - Latitude: ' + place.latitude + ',' + 'Longitude: ' + place.longitude);
    var intent = mobicontrol.android.createIntent()
        .withAction("android.intent.action.VIEW")
        .withData("google.navigation:q=" + place.latitude + "," + place.longitude);
    mobicontrol.android.startActivity(intent);
}

async, static locate(callbackFunction, invocationTimeoutInMillisopt)

Locate the device.

See also Location tutorial.

Parameters:
Name Type Attributes Default Description
callbackFunction mobicontrol.location.locateCallback JavaScript function which is called when the device location attempt completes.
invocationTimeoutInMillis number <optional>
120000 Invocation timeout in milliseconds. If the callback function isn't invoked before the timeout expires, it will be called with the timed-out result.
Since:
Example
mobicontrol.location.locate(onLocationEvent);

function onLocationEvent(result) {
    if (result.isSuccessful) {
        var location = result.location;
        mobicontrol.log.info(
            "Latitude: " + location.latitude + ", " +
            "Longitude: " + location.longitude
        );
    }
}

Type Definitions

locateCallback(result)

Callback function for mobicontrol.location.locate.
Parameters:
Name Type Description
result object Result of the device location attempt.
Properties
Name Type Description
location mobicontrol.location.Location The current device location or null if the device could not be located.
error mobicontrol.location.LocationError Detailed error conditions in case of failure.

This value is null when the callback is successful or when there is a timeout.

isSuccessful boolean Success status of the callback.

true if the callback completed successfully, false otherwise.

isTimedOut boolean Timeout status of the callback.

true if the callback was timed out, false otherwise.

Note: A timeout is considered a failure, so if the timeout status is true, failure status is true as well, and success status is false.

isFailed boolean Failure status of the callback.

true if the callback failed, false otherwise.

Since: