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