Commit 3a09facb authored by Chris Scott's avatar Chris Scott

Wrong config param name notifyOnEnter vs notifyOnEntry. Add error-checking to...

Wrong config param name notifyOnEnter vs notifyOnEntry.  Add error-checking to JS api addGeofence:  enforce has set either notifyOnEntry OR notifyOnExit
parent c5e439c0
...@@ -31,6 +31,7 @@ public class CDVBackgroundGeolocation extends CordovaPlugin { ...@@ -31,6 +31,7 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
public static final String ACTION_START = "start"; public static final String ACTION_START = "start";
public static final String ACTION_STOP = "stop"; public static final String ACTION_STOP = "stop";
public static final String ACTION_FINISH = "finish";
public static final String ACTION_ON_PACE_CHANGE = "onPaceChange"; public static final String ACTION_ON_PACE_CHANGE = "onPaceChange";
public static final String ACTION_CONFIGURE = "configure"; public static final String ACTION_CONFIGURE = "configure";
public static final String ACTION_SET_CONFIG = "setConfig"; public static final String ACTION_SET_CONFIG = "setConfig";
...@@ -88,9 +89,13 @@ public class CDVBackgroundGeolocation extends CordovaPlugin { ...@@ -88,9 +89,13 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
this.setEnabled(true); this.setEnabled(true);
callbackContext.success(); callbackContext.success();
} else if (ACTION_STOP.equalsIgnoreCase(action)) { } else if (ACTION_STOP.equalsIgnoreCase(action)) {
// No implementation to stop background-tasks with Android. Just say "success"
result = true; result = true;
this.setEnabled(false); this.setEnabled(false);
callbackContext.success(); callbackContext.success();
} else if (ACTION_FINISH.equalsIgnoreCase(action)) {
result = true;
callbackContext.success();
} else if (ACTION_CONFIGURE.equalsIgnoreCase(action)) { } else if (ACTION_CONFIGURE.equalsIgnoreCase(action)) {
result = applyConfig(data); result = applyConfig(data);
if (result) { if (result) {
...@@ -166,8 +171,8 @@ public class CDVBackgroundGeolocation extends CordovaPlugin { ...@@ -166,8 +171,8 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
event.putDouble("latitude", config.getDouble("latitude")); event.putDouble("latitude", config.getDouble("latitude"));
event.putDouble("longitude", config.getDouble("longitude")); event.putDouble("longitude", config.getDouble("longitude"));
event.putString("identifier", config.getString("identifier")); event.putString("identifier", config.getString("identifier"));
if (config.has("notifyOnEnter")) { if (config.has("notifyOnEntry")) {
event.putBoolean("notifyOnEnter", config.getBoolean("notifyOnEnter")); event.putBoolean("notifyOnEntry", config.getBoolean("notifyOnEntry"));
} }
if (config.has("notifyOnExit")) { if (config.has("notifyOnExit")) {
event.putBoolean("notifyOnExit", config.getBoolean("notifyOnExit")); event.putBoolean("notifyOnExit", config.getBoolean("notifyOnExit"));
......
...@@ -184,6 +184,9 @@ module.exports = { ...@@ -184,6 +184,9 @@ module.exports = {
if (!config.radius) { if (!config.radius) {
throw "#addGeofence requires a #radius"; throw "#addGeofence requires a #radius";
} }
if ( (typeof(config.notifyOnEnter) === 'undefined') && (typeof(config.notifyOnExit) === 'undefined') ) {
throw "#addGeofence requires at least notifyOnEnter {Boolean} and/or #notifyOnExit {Boolean}";
}
exec(success || function() {}, exec(success || function() {},
failure || function() {}, failure || function() {},
'BackgroundGeoLocation', 'BackgroundGeoLocation',
......
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