Commit 7a5664bc authored by Chris Scott's avatar Chris Scott

Implement removeGeofence method. Fix Android bug removing geofences on Service destroy

parent 0f8aca10
......@@ -28,6 +28,7 @@
- (void) resetOdometer:(CDVInvokedUrlCommand *)command;
- (void) addGeofence:(CDVInvokedUrlCommand *)command;
- (void) removeGeofence:(CDVInvokedUrlCommand *)command;
- (void) getGeofences:(CDVInvokedUrlCommand *)command;
- (void) onGeofence:(CDVInvokedUrlCommand *)command;
- (void) playSound:(CDVInvokedUrlCommand *)command;
@end
......
......@@ -231,6 +231,22 @@
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}
- (void) getGeofences:(CDVInvokedUrlCommand*)command
{
NSMutableArray *rs = [[NSMutableArray alloc] init];
for (CLRegion *geofence in [bgGeo getGeofences]) {
[rs addObject:@{
@"identifier":geofence.identifier,
@"radius": @(geofence.radius),
@"latitude": @(geofence.center.latitude),
@"longitude": @(geofence.center.longitude)
}];
}
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:rs];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}
- (void) onGeofence:(CDVInvokedUrlCommand*)command
{
if (self.geofenceListeners == nil) {
......
......@@ -5,7 +5,7 @@
@interface TSLocationManager : NSObject <CLLocationManagerDelegate>
@property (nonatomic) CLLocationDistance odometer;
@property (nonatomic, strong) CLLocationManager* locationManager;
- (void) configure:(NSDictionary*)config;
- (void) start;
- (void) stop;
......@@ -23,6 +23,7 @@
- (NSDictionary*) locationToDictionary:(CLLocation*)location;
- (void) addGeofence:(NSString*)identifier radius:(CLLocationDistance)radius latitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude notifyOnEntry:(BOOL)notifyOnEntry notifyOnExit:(BOOL)notifyOnExit;
- (BOOL) removeGeofence:(NSString*)identifier;
- (NSArray*) getGeofences;
- (void) playSound:(SystemSoundID)soundId;
@end
......@@ -6,7 +6,7 @@
<dict>
<key>Headers/TSLocationManager.h</key>
<data>
0rtf3tEfqeHo6WQSpvbXktE2waw=
D1StsS2xjuq9sRvFuNw3O74hUYA=
</data>
<key>Info.plist</key>
<data>
......@@ -21,7 +21,7 @@
<dict>
<key>Headers/TSLocationManager.h</key>
<data>
0rtf3tEfqeHo6WQSpvbXktE2waw=
D1StsS2xjuq9sRvFuNw3O74hUYA=
</data>
<key>Modules/module.modulemap</key>
<data>
......
......@@ -210,10 +210,10 @@ module.exports = {
}
var me = this;
var mySuccess = function(params) {
var identifier = params.identifier,
taskId = params.taskId || 'task-id-undefined';
success.call(me, identifier, taskId);
}
var taskId = params.taskId || 'task-id-undefined';
delete(params.taskId);
success.call(me, params, taskId);
};
exec(mySuccess,
failure || function() {},
'BackgroundGeoLocation',
......@@ -221,6 +221,16 @@ module.exports = {
[]);
},
/**
* Fetch a list of all monitored geofences
*/
getGeofences: function(success, failure) {
exec(success || function() {},
failure || function() {},
'BackgroundGeoLocation',
'getGeofences',
[]);
},
/**
* Play a system sound. This is totally experimental.
* iOS http://iphonedevwiki.net/index.php/AudioServices
* Android:
......
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