Commit a49d9f2e authored by Chris Scott's avatar Chris Scott

Add hash-merge method used in setConfig for handy access to config params plugin is configured with

parent d982599f
......@@ -338,15 +338,15 @@
NSMutableDictionary *returnInfo;
returnInfo = [NSMutableDictionary dictionaryWithCapacity:10];
NSNumber* timestamp = [NSNumber numberWithDouble:([stationaryLocation.timestamp timeIntervalSince1970] * 1000)];
NSNumber* timestamp = [NSNumber numberWithDouble:([location.timestamp timeIntervalSince1970] * 1000)];
[returnInfo setObject:timestamp forKey:@"timestamp"];
[returnInfo setObject:[NSNumber numberWithDouble:stationaryLocation.speed] forKey:@"speed"];
[returnInfo setObject:[NSNumber numberWithDouble:stationaryLocation.verticalAccuracy] forKey:@"altitudeAccuracy"];
[returnInfo setObject:[NSNumber numberWithDouble:stationaryLocation.horizontalAccuracy] forKey:@"accuracy"];
[returnInfo setObject:[NSNumber numberWithDouble:stationaryLocation.course] forKey:@"heading"];
[returnInfo setObject:[NSNumber numberWithDouble:stationaryLocation.altitude] forKey:@"altitude"];
[returnInfo setObject:[NSNumber numberWithDouble:stationaryLocation.coordinate.latitude] forKey:@"latitude"];
[returnInfo setObject:[NSNumber numberWithDouble:stationaryLocation.coordinate.longitude] forKey:@"longitude"];
[returnInfo setObject:[NSNumber numberWithDouble:location.speed] forKey:@"speed"];
[returnInfo setObject:[NSNumber numberWithDouble:location.verticalAccuracy] forKey:@"altitudeAccuracy"];
[returnInfo setObject:[NSNumber numberWithDouble:location.horizontalAccuracy] forKey:@"accuracy"];
[returnInfo setObject:[NSNumber numberWithDouble:location.course] forKey:@"heading"];
[returnInfo setObject:[NSNumber numberWithDouble:location.altitude] forKey:@"altitude"];
[returnInfo setObject:[NSNumber numberWithDouble:location.coordinate.latitude] forKey:@"latitude"];
[returnInfo setObject:[NSNumber numberWithDouble:location.coordinate.longitude] forKey:@"longitude"];
return returnInfo;
}
......@@ -503,11 +503,11 @@
NSLog(@"- CDVBackgroundGeoLocation#sync");
NSLog(@" type: %@, position: %@,%@ speed: %@", [data objectForKey:@"location_type"], [data objectForKey:@"latitude"], [data objectForKey:@"longitude"], [data objectForKey:@"speed"]);
if (isDebugging) {
[self notify:[NSString stringWithFormat:@"Location update: %s\nSPD: %@ | DF: %0.1f | ACY: %@",
[self notify:[NSString stringWithFormat:@"Location update: %s\nSPD: %0.0f | DF: %ld | ACY: %0.0f",
((isMoving) ? "MOVING" : "STATIONARY"),
[data objectForKey:@"speed"],
locationManager.distanceFilter,
[data objectForKey:@"accuracy"]]];
[[data objectForKey:@"speed"] doubleValue],
(long) locationManager.distanceFilter,
[[data objectForKey:@"accuracy"] doubleValue]]];
AudioServicesPlaySystemSound (locationSyncSound);
}
......
......@@ -10,7 +10,7 @@ module.exports = {
config: {},
configure: function(success, failure, config) {
this.config = config || {};
this.config = config;
var params = JSON.stringify(config.params || {}),
headers = JSON.stringify(config.headers || {}),
url = config.url || 'BackgroundGeoLocation_url',
......@@ -65,7 +65,7 @@ module.exports = {
* @param {Integer} timeout
*/
setConfig: function(success, failure, config) {
this.config = config || {};
this.apply(this.config, config);
exec(success || function() {},
failure || function() {},
'BackgroundGeoLocation',
......@@ -82,6 +82,11 @@ module.exports = {
'getStationaryLocation',
[]);
},
/**
* Add a stationary-region listener. Whenever the devices enters "stationary-mode", your #success callback will be executed with #location param containing #radius of region
* @param {Function} success
* @param {Function} failure [optional] NOT IMPLEMENTED
*/
onStationary: function(success, failure) {
var me = this;
success = success || function() {};
......@@ -94,5 +99,14 @@ module.exports = {
'BackgroundGeoLocation',
'addStationaryRegionListener',
[]);
},
apply: function(destination, source) {
source = source || {};
for (var property in source) {
if (source.hasOwnProperty(property)) {
destination[property] = source[property];
}
}
return destination;
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment