Commit 32e6f4d4 authored by Chris Scott's avatar Chris Scott

Cast timestamp to Javascript new Date() before sending to callback. Fix bug...

Cast timestamp to Javascript new Date() before sending to callback.  Fix bug in persistence layer on Android wiht new timestamp ISO-8601 format.  Add device_id to HTTP POST for both Android & iOS
parent b3c69c6d
......@@ -8,6 +8,8 @@ import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONException;
import com.google.android.gms.location.ActivityRecognitionResult;
import com.google.android.gms.location.DetectedActivity;
import com.transistorsoft.locationmanager.BackgroundGeolocationService;
import com.transistorsoft.locationmanager.BackgroundGeolocationService.PaceChangeEvent;
import com.transistorsoft.locationmanager.BackgroundGeolocationService.PausedEvent;
......@@ -39,6 +41,8 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
private Intent backgroundServiceIntent;
private DetectedActivity currentActivity;
// Geolocation callback
private CallbackContext locationCallback;
// Called when DetectedActivity is STILL
......@@ -205,12 +209,23 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
}
}
/**
* EventBus listener for ARS
* @param {ActivityRecognitionResult} result
*/
public void onEventMainThread(ActivityRecognitionResult result) {
currentActivity = result.getMostProbableActivity();
String activityName = BackgroundGeolocationService.getActivityName(currentActivity.getType());
int confidence = currentActivity.getConfidence();
Log.i(TAG, "----------- currentActivity: " + currentActivity);
}
/**
* EventBus listener
* @param {Location} location
*/
public void onEventMainThread(Location location) {
PluginResult result = new PluginResult(PluginResult.Status.OK, BackgroundGeolocationService.locationToJson(location));
PluginResult result;
result = new PluginResult(PluginResult.Status.OK, BackgroundGeolocationService.locationToJson(location, currentActivity));
result.setKeepCallback(true);
if (location instanceof com.transistorsoft.locationmanager.BackgroundGeolocationService.StationaryLocation) {
......
......@@ -20,8 +20,15 @@ module.exports = {
configure: function(success, failure, config) {
config = config || {};
this.config = config;
exec(success || function() {},
success = success || function(location) {};
var mySuccess = function(location) {
// Transform timestamp to Date instance.
if (location.timestamp) {
location.timestamp = new Date(location.timestamp);
}
success.call(this, location);
}
exec(mySuccess,
failure || function() {},
'BackgroundGeoLocation',
'configure',
......
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