Skip to content

Commit

Permalink
Merge pull request #3 from roam-ai/v0.0.4
Browse files Browse the repository at this point in the history
v0.0.4
  • Loading branch information
Jothi Priyadharshan authored Aug 17, 2022
2 parents 4147ad7 + 080cde3 commit ff33e93
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@

- Fixed location listener
- Added `safeRemoveCallback` method to prevent app side crash for terminated state

## 0.0.4

- Fixed location object in the location receiver.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "roam-cordova",
"version": "0.0.3",
"version": "0.0.4",
"description": "This plugin allows to use the Roam.ai SDK in your React Native mobile application on iOS and Android.",
"homepage": "https://roam.ai",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin
id="roam-cordova"
version="0.0.3"
version="0.0.4"
xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android">
<name>roam</name>
Expand Down
23 changes: 22 additions & 1 deletion src/android/src/main/java/com/roam/cordova/CDVRoam.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.cordova.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class CDVRoam extends CordovaPlugin {
private static CallbackContext locationCallbackContext;
Expand Down Expand Up @@ -599,7 +600,27 @@ public static class RoamCordovaReceiver extends RoamReceiver{
@Override
public void onLocationUpdated(Context context, RoamLocation roamLocation) {
super.onLocationUpdated(context, roamLocation);
String serializedLocation = new GsonBuilder().create().toJson(roamLocation);
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("userId", roamLocation.getUserId());
jsonObject.put("activity", roamLocation.getActivity());
jsonObject.put("recordedAt", roamLocation.getRecordedAt());
jsonObject.put("timezoneOffset", roamLocation.getTimezoneOffset());
jsonObject.put("metadata", (roamLocation.getMetadata() != null) ? roamLocation.getMetadata().toString() : "");
jsonObject.put("batteryStatus", roamLocation.getBatteryStatus());
jsonObject.put("networkStatus", roamLocation.getNetworkStatus());
jsonObject.put("provider", roamLocation.getLocation().getProvider());
jsonObject.put("time", roamLocation.getLocation().getTime());
jsonObject.put("latitude", roamLocation.getLocation().getLatitude());
jsonObject.put("longitude", roamLocation.getLocation().getLongitude());
jsonObject.put("altitude", roamLocation.getLocation().getAltitude());
jsonObject.put("speed", roamLocation.getLocation().getSpeed());
jsonObject.put("bearing", roamLocation.getLocation().getBearing());
jsonObject.put("accuracy", roamLocation.getLocation().getAccuracy());
}catch (Exception e){
e.printStackTrace();
}
String serializedLocation = jsonObject.toString();
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, serializedLocation);
pluginResult.setKeepCallback(true);
if (CDVRoam.locationCallbackContext != null) {
Expand Down

0 comments on commit ff33e93

Please sign in to comment.