MobileCRM.Platform.watchLocationUpdates - Resconet/JSBridge GitHub Wiki
[v18.2] Registers or unregisters a handler for location updates.
When the location is updated, the handler is called with a MobileCRM.Location object having latitude, longitude and timestamp properties.
Argument | Type | Description |
---|---|---|
handler | function(location) | Handler function which will be called each time when the location is updated. The location argument will carry an object with latitude, longitude and timestamp properties. |
bind | Boolean | Indicates whether to bind or unbind handler. |
scope | Optional scope for calling the handler; set "null" to call the handler in global scope. |
This example demonstrate how to watch for geo-location changes continuously.
function watchForLocationUpdates(start) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield MobileCRM.Platform.watchLocationUpdates(onLocationFound, start ? true : false, this);
}
catch (err) {
MobileCRM.bridge.alert("Error registering for location updates: " + err);
}
});
}
function onLocationFound(location) {
/// <param name="location" type="MobileCRM.Location"/>
MobileCRM.bridge.alert(`Location found: [${location.latitude},${location.longitude}] from ${location.timestamp}`);
}
// watchForLocationUpdates(true); // To start watching for location updates.
// watchForLocationUpdates(false); // To stop watching for location updates.