Commit f0fdd64d authored by Zachary Giles's avatar Zachary Giles

finish headers

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