Commit f0fdd64d authored by Zachary Giles's avatar Zachary Giles

finish headers

parent a9999168
......@@ -25,6 +25,7 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
private String url;
private String params;
private String headers;
private String stationaryRadius = "30";
private String desiredAccuracy = "100";
private String distanceFilter = "30";
......@@ -38,12 +39,13 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
if (ACTION_START.equalsIgnoreCase(action) && !isEnabled) {
result = true;
if (params == null || url == null) {
if (params == null || headers == null || url == null) {
callbackContext.error("Call configure before calling start");
} else {
callbackContext.success();
updateServiceIntent.putExtra("url", url);
updateServiceIntent.putExtra("params", params);
updateServiceIntent.putExtra("headers", headers);
updateServiceIntent.putExtra("stationaryRadius", stationaryRadius);
updateServiceIntent.putExtra("desiredAccuracy", desiredAccuracy);
updateServiceIntent.putExtra("distanceFilter", distanceFilter);
......@@ -62,14 +64,15 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
} else if (ACTION_CONFIGURE.equalsIgnoreCase(action)) {
result = true;
try {
// [params, url, stationaryRadius, distanceFilter, locationTimeout, desiredAccuracy, debug]);
// [params, headers url, stationaryRadius, distanceFilter, locationTimeout, desiredAccuracy, debug]);
this.params = data.getString(0);
this.url = data.getString(1);
this.stationaryRadius = data.getString(2);
this.distanceFilter = data.getString(3);
this.locationTimeout = data.getString(4);
this.desiredAccuracy = data.getString(5);
this.isDebugging = data.getString(6);
this.headers = data.getString(1);
this.url = data.getString(2);
this.stationaryRadius = data.getString(3);
this.distanceFilter = data.getString(4);
this.locationTimeout = data.getString(5);
this.desiredAccuracy = data.getString(6);
this.isDebugging = data.getString(7);
} catch (JSONException e) {
callbackContext.error("authToken/url required as parameters: " + e.getMessage());
......
......@@ -665,11 +665,13 @@ public class LocationUpdateService extends Service implements LocationListener {
StringEntity se = new StringEntity(params.toString());
request.setEntity(se);
request.setHeader("Accept", "application/json");
request.setHeader("Content-type", "application/json");
Iterator<String> headkeys = headers.keys();
while( headkeys.hasNext() ){
if(headkeys.next() != null) {
String headkey = (String)headkeys.next();
String headkey = headkeys.next();
if(headkey != null) {
Log.d(TAG, "Adding Header: " + headkey + " : " + (String)headers.getString(headkey));
request.setHeader(headkey, (String)headers.getString(headkey));
}
......
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