Specifies whether a notification should be sent after dwelling in the GeoFence for some amount of time. Only for use with Android devices.
Note:
When notifOnDwell is true, a loiteringDelay must be provided as well.
To obtain details about the user’s current location.
function getLocation () {
OnymosGeo.getLocation(
function getLocationSuccess (locationObj) {
/* ------
locationObj = {
latitude: The latitude coordinate of a location. Between -90.0 to 90.0 degrees.,
longitude: The longitude coordinate of a location. Between -180.0 to 180.0 degrees.,
altitude: The altitude of a location, if available, in meters.,
course: The direction of the device's movement, if available, in degrees relative to north.,
speed: The speed, if available, in meters per second.,
horizontalAccuracy: The estimated horizontal accuracy of the location, if available, in meters. ,
verticalAccuracy: The estimated vertical accuracy of the location, if available, in meters.,
timestamp: The time location was retrieved, in Unix epoch time.
}; ------ */
},
function getLocationFailure (error) {
console.log(error);
});
} /* end function getLocation */
To continuously track the user’s current location. May also provide parameters that affect the frequency or accuracy of location updates, which will also affect battery usage.
function startLocationUpdates () {
OnymosGeo.startLocationUpdates(
function startUpdatesSuccess (locationObj) {
console.log(locationObj);
},
function startUpdatesFailed (error) {
console.log(error);
},
options);
} /* end function startLocationUpdates */
Number
The minimum horizontal distance that must be traveled before an update, in meters.
Number
The minimum time before a location update, in seconds. Only for use with Android devices.
Constant
The desired accuracy of the location updates. Only for use with iOS devices.
Android Usage Example
{
minDistBeforeUpdate: 20,
minTimeBeforeUpdate: 15
}
iOS Usage Example
{
minDistBeforeUpdate: 20,
desiredAccuracy: OnymosGeoConstants.Accuracy.best
}
To stop tracking user and end updates about the user’s current location.
function stopLocationUpdates () {
OnymosGeo.stopLocationUpdates(
function stopUpdatesSuccess (status) {
console.log(status);
},
function stopUpdatesFailure (error) {
console.log(error);
});
} /* end function stopLocationUpdates */
To obtain details about a location by using its latitude and longitude coordinates.
function getLocationDetails (latitude, longitude) {
OnymosGeo.getLocationDetails(
latitude,
longitude,
function getDetailsSuccess (locInfoObj) {
/* ------
locInfoObject = {
countryName: The name of the country of the location, if known.,
countryCode: The country code of the location, for example, "US", if known.,
adminArea: The administrative area of the location, for example, "CA", if known.,
subAdminArea: The sub-adminstraive area, if known.,
locality: The locality (city) of the location, if known.,
subLocality: The sub-locality (additional city-level info) of the location, if known.,
thoroughfare: The street address of the location, for example, "Main Street", if known.,
subThoroughfare: The sub-thoroughfare (additional streel-level info) of the location, if known.,
postalCode: The postal code of the address, if known.,
timeZone: The timezone of the location, if known. iOS only.
}; ------ */
},
function getDetailsFailed (error) {
console.log(error);
});
} /* end function getLocationDetails */
Number
The latitude coordinate of a location. Falls within the range of -90.0 to 90.0 degrees.
Number
The longitude coordinate of a location. Falls within the range of -180.0 to 180.0 degrees.
To obtain the latitude and longitude coordinates from a given address.
function getLocationFromAddress (address) {
OnymosGeo.getLocationFromAddress(
address,
function getLocationSuccess (coordsObj) {
/* ------
coordsObject = {
latitude: The latitude coordinate of a location. Between -90.0 to 90.0 degrees.,
longitude: The longitude coordinate of a location. Between -180.0 to 180.0 degrees.
}; ------ */
},
function getLocationFailed (error) {
console.log(error);
});
} /* end function getLocationFromAddress */
String
An address or name of a location. Can be general (e.g., “Dalvik, Iceland”) or specific (e.g., 565 University Ave, Los Gatos, CA 95032).
To set or reset parameters that describe the accuracy and frequency of location updates. This will affect battery usage. If fields are not provided, default values will be used.
function setPowerSetting () {
OnymosGeo.setLocationPowerSetting(
function setPowerSettingsSuccess (status) {
console.log(status);
},
function setPowerSettingsFailed (error) {
console.log(error);
},
options);
} /* end function setPowerSetting */
Number
The minimum horizontal distance that must be traveled before an update, in meters.
Number
The minimum time before a location update, in seconds. Only for use with Android devices.
Constant
The desired accuracy of the location updates. Only for use with iOS devices.
Android Usage Example
{
minDistBeforeUpdate: 20,
minTimeBeforeUpdate: 15
}
iOS Usage Example
{
minDistBeforeUpdate: 20,
desiredAccuracy: OnymosGeoConstants.Accuracy.best
}
To set or reset parameters that describe the accuracy and frequency of location updates. This will affect battery usage. If fields are not provided, default values will be used.
function createGeoFence (latitude, longitude, radius) {
OnymosGeo.createGeoFence(
latitude,
longitude,
radius,
setActive,
function createSuccess (geoFenceObject) {
/* ------
geoFenceObject = {
id: The unique string id of the GeoFence.,
latitude: The latitude coordinate of a location. Falls within the range of -90.0 to 90.0 degrees.,
longitude: The longitude coordinate of a location. Falls within the range of -180.0 to 180.0 degrees.,
radius: The radius of the GeoFence, in meters.,
monitoring: Boolean indicating whether the GeoFence is currently being monitored.,
localNotifTitle: The GeoFence's notification title, if provided.,
localNotifMessage: The GeoFence's notification message, if provided.,
notifOnEntry: Boolean indication if a notification should be sent on entry of this GeoFence, if specified.,
notifOnExit: Boolean indication if a notification should be sent on exit of this GeoFence, if specified.,
notifOnDwell: Boolean indication if a notification should be sent after dwelling in this GeoFence, if specified.,
loiteringDelay: The time spent in a GeoFence before a notification triggers for a dwell notification, if specified.,
activeDuration: The duration of time a GeoFence is active in milliseconds, if provided.
}; ------ */
},
function createFailed (error) {
console.log(error);
},
options);
} /* end function createGeoFence */
Number
The latitude coordinate of a location. Falls within the range of -90.0 to 90.0 degrees.
Number
The longitude coordinate of a location. Falls within the range of -180.0 to 180.0 degrees.
Number
The radius of the GeoFence, in meters.
Boolean
Specifies whether the GeoFence should be monitored upon creation or not.
String
The text for the title of a the notification associated with this GeoFence.
String
The text for the message of a the notification associated with this GeoFence.
Boolean
Specifies whether a notification should be sent upon entering the GeoFence.
Boolean
Specifies whether a notification should be sent upon exiting the GeoFence.
Boolean
Specifies whether a notification should be sent after dwelling in the GeoFence for some amount of time. Only for use with Android devices.
Note:
When notifOnDwell is true, a loiteringDelay must be provided as well.
Number
The time that must pass after entering a GeoFence boundary before a notification should be delivered. Only for use with Android devices.
Note:
This is only used when a dwell transition is specified. When notifOnDwell is true, a loiteringDelay must be provided as well.
Number
The time that the GeoFence is active in milliseconds. After the duration ends, the GeoFence will automatically be unmonitored and removed. If not specified, the GeoFence will not expire automatically, and must be unmonitored or removed manually. Only available for Android devices.
Standard Usage Example
{
localNotifTitle: “GeoFence Notification”,
localNotifMessage: “Hello”,
notifOnEntry: true
}
Dwelling Usage Example
{
localNotifTitle: “GeoFence Notification”,
localNotifMessage: “Hello”,
notifOnEntry: true
notifOnDwell: true
loiteringDelay: 3000,
activeDuration: 3600000
}
To set a particular GeoFence to monitored if it exists and is currently unmonitored.
function monitor (id) {
OnymosGeo.setGeoFenceActive(
id,
function activateFenceSuccess (status) {
console.log(status);
},
function activateFenceFailure (error) {
console.log(error);
},
options);
} /* end function monitor */
String
The unique id of the GeoFence.
Boolean
Specifies whether a notification should be sent upon entering the GeoFence.
Boolean
Specifies whether a notification should be sent after dwelling in the GeoFence for some amount of time. Only for use with Android devices.
Note:
When notifOnDwell is true, a loiteringDelay must be provided as well.
Boolean
Specifies whether a notification should be sent after dwelling in the GeoFence for some amount of time. Only for use with Android devices.
Note:
When notifOnDwell is true, a loiteringDelay must be provided as well.
Number
The time that must pass after entering a GeoFence boundary before a notification should be delivered. Only for use with Android devices.
Note:
This is only used when a dwell transition is specified. When notifOnDwell is true, a loiteringDelay must be provided as well.
Number
The time that the GeoFence is active in milliseconds. After the duration ends, the GeoFence will automatically be unmonitored and removed. If not specified, the GeoFence will not expire automatically, and must be unmonitored or removed manually. Only available for Android devices.
Standard Usage Example
{
notifOnEntry: true
}
Dwelling Usage Example
{
notifOnEntry: true,
notifOnDwell: true,
loiteringDelay: 3000,
activeDuration: 3600000
}
To set a particular GeoFence to unmonitored if it exists and is currently monitored.
function unmonitor (id) {
OnymosGeo.setGeoFenceInactive(
id,
function deactivateFenceSuccess (status) {
console.log(status);
},
function deactivateFenceFailure (error) {
console.log(error);
});
} /* end function unmonitor */
String
The unique id of the GeoFence.
To retrieve the array of currently monitored GeoFences.
function getMonitoredGeoFences () {
var geoFenceArray = OnymosGeo.getMonitoredGeoFences();
/* ------
geoFenceArray[] = {
id: The unique string id of the GeoFence.>,
latitude: The latitude coordinate of a location. Falls within the range of -90.0 to 90.0 degrees.,
longitude: The longitude coordinate of a location. Falls within the range of -180.0 to 180.0 degrees.,
radius: The radius of the GeoFence, in meters.,
monitoring: Boolean indicating whether the GeoFence is currently being monitored.,
localNotifTitle: The GeoFence's notification title, if provided.,
localNotifMessage: The GeoFence's notification message, if provided.,
notifOnEntry: Boolean indication if a notification should be sent on entry of this GeoFence, if specified.,
notifOnExit: Boolean indication if a notification should be sent on exit of this GeoFence, if specified.,
notifOnDwell: Boolean indication if a notification should be sent after dwelling in this GeoFence, if specified.,
loiteringDelay: The time spent in a GeoFence before a notification triggers for a dwell notification, if specified.,
activeDuration: The duration of time a GeoFence is active in milliseconds, if provided.
}; ------ */
} /* end function getMonitoredGeoFences */
To retrieve the array of currently unmonitored GeoFences.
function getUnmonitoredGeoFences () {
var geoFenceArray = OnymosGeo.getUnmonitoredGeoFences();
/* ------
geoFenceArray[] = {
id: The unique string id of the GeoFence.,
latitude: The latitude coordinate of a location. Falls within the range of -90.0 to 90.0 degrees.,
longitude: The longitude coordinate of a location. Falls within the range of -180.0 to 180.0 degrees.,
radius: The radius of the GeoFence, in meters.,
monitoring: Boolean indicating whether the GeoFence is currently being monitored.,
localNotifTitle: The GeoFence's notification title, if provided.,
localNotifMessage: The GeoFence's notification message, if provided.,
notifOnEntry: Boolean indication if a notification should be sent on entry of this GeoFence, if specified.,
notifOnExit: Boolean indication if a notification should be sent on exit of this GeoFence, if specified.,
notifOnDwell: Boolean indication if a notification should be sent after dwelling in this GeoFence, if specified.,
loiteringDelay: The time spent in a GeoFence before a notification triggers for a dwell notification, if specified.,
activeDuration: The duration of time a GeoFence is active in milliseconds, if provided.
}; ------ */
} /* end function getUnmonitoredGeoFences */
To delete a particular GeoFence. If the GeoFence is being monitored, it will be unmonitored first.
function deleteGeoFence (id) {
OnymosGeo.deleteGeoFence(
id,
function deleteFenceSuccess (status) {
console.log(status);
},
function deleteFenceFailed (error) {
console.log(error);
});
} /* end function deleteGeoFence */
String
The unique id of the GeoFence.
To delete all GeoFences. Unmonitors GeoFences if they are monitored, then deletes them. Deletes based on the monitoringStatus if given, else deletes all GeoFences.
function deleteAllFences () {
OnymosGeo.deleteAllGeoFences(
function deleteAllSuccess (status) {
console.log(status);
},
function deleteAllFailed (error) {
console.log(error);
},
options);
} /* end function deleteAllFences */
String
One of “monitored”, “unmonitored”, or “both”. The active status of the GeoFences to be deleted. Providing “monitored” will delete all currently monitored GeoFences, “unmonitored” will delete unmonitored GeoFences, and “both” will delete all GeoFences.
Usage Example
{
monitoringStatus: “monitored”
}
To check if a location lies within any of the active GeoFence boundaries. Uses a specific location if provided, otherwise this function will use the user’s location. Finds all of the GeoFences that the location lies within, if any.
function isLocationInGeoFence (latitude, longitude) {
OnymosGeo.isLocationInGeoFence(
function isLocationInSuccess (geoFenceArray) {
/* ------
geoFenceArray[] = {
id: The unique string id of the GeoFence.,
latitude: The latitude coordinate of a location. Falls within the range of -90.0 to 90.0 degrees.,
longitude: The longitude coordinate of a location. Falls within the range of -180.0 to 180.0 degrees.,
radius: The radius of the GeoFence, in meters.,
monitoring: Boolean indicating whether the GeoFence is currently being monitored.,
localNotifTitle: The GeoFence's notification title, if provided.,
localNotifMessage: The GeoFence's notification message, if provided.,
notifOnEntry: Boolean indication if a notification should be sent on entry of this GeoFence, if specified.,
notifOnExit: Boolean indication if a notification should be sent on exit of this GeoFence, if specified.,
notifOnDwell: Boolean indication if a notification should be sent after dwelling in this GeoFence, if specified.,
loiteringDelay: The time spent in a GeoFence before a notification triggers for a dwell notification, if specified.,
activeDuration: The duration of time a GeoFence is active in milliseconds, if provided.
}; ------ */
},
function isLocationInFailed (error) {
console.log(error);
},
options);
} /* end function isLocationInGeoFence */
Number
The latitude coordinate of a location. Falls within the range of -90.0 to 90.0 degrees.
Number
The longitude coordinate of a location. Falls within the range of -180.0 to 180.0 degrees.
Usage Example
{
latitude: 42.09,
longitude: -121.1
}
To find the closest active GeoFence to a location using the GeoFence’s center. Uses a specific location if coordinates are provided, otherwise this function will use the user’s location.
function closestGeoFence (latitude, longitude) {
OnymosGeo.closestGeoFence(
function findClosestSuccess (geoFenceObject) {
/* ------
geoFenceObject = {
id: The unique string id of the GeoFence.,
latitude: The latitude coordinate of a location. Falls within the range of -90.0 to 90.0 degrees.,
longitude: The longitude coordinate of a location. Falls within the range of -180.0 to 180.0 degrees.,
radius: The radius of the GeoFence, in meters.,
monitoring: Boolean indicating whether the GeoFence is currently being monitored.,
localNotifTitle: The GeoFence's notification title, if provided.,
localNotifMessage: The GeoFence's notification message, if provided.,
notifOnEntry: Boolean indication if a notification should be sent on entry of this GeoFence, if specified.,
notifOnExit: Boolean indication if a notification should be sent on exit of this GeoFence, if specified.,
notifOnDwell: Boolean indication if a notification should be sent after dwelling in this GeoFence, if specified.,
loiteringDelay: The time spent in a GeoFence before a notification triggers for a dwell notification, if specified.,
activeDuration: The duration of time a GeoFence is active in milliseconds, if provided.
}; ------ */
},
function findClosestFailed (error) {
console.log(error);
},
options);
} /* end function closestGeoFence */
Number
The latitude coordinate of a location. Falls within the range of -90.0 to 90.0 degrees.
Number
The longitude coordinate of a location. Falls within the range of -180.0 to 180.0 degrees.
Usage Example
{
latitude: 42.09,
longitude: -121.1
}
To obtain the distance between a location and the specified GeoFence’s center, in meters. Uses a specific location if coordinates are provided, otherwise this function will use the user’s location.
function getDistFromGeoFence (id, latitude, longitude) {
OnymosGeo.getDistFromGeoFence(
id,
function getDistSuccess (distance) {
//do something with distance (the distance between the GeoFence and location in meters)
},
function getDistFailed (error) {
console.log(error);
},
options);
} /* end function getDistFromGeoFence */
String
The unique id of the GeoFence.
Number
The latitude coordinate of a location. Falls within the range of -90.0 to 90.0 degrees.
Number
The longitude coordinate of a location. Falls within the range of -180.0 to 180.0 degrees.
Usage Example
{
latitude: 42.09,
longitude: -121.1
}
Download our free white paper today to learn how Onymos Features can maximize the value of your developer resources — and shave days or weeks off your development timeline.