private NetmeraDeviceDetail jsonArraytoNetmeraDeviceDetail(JSONArray array)
      throws JSONException, NetmeraException {
    NetmeraDeviceDetail deviceDetail = new NetmeraDeviceDetail(senderID);
    JSONObject obj = array.getJSONObject(0);

    if (obj.has("tags")) {
      JSONArray tags = obj.getJSONArray("tags");
      ArrayList<String> group = new ArrayList<String>();
      for (int i = 0; i < tags.length(); i++) {
        group.add(tags.getString(i));
      }

      deviceDetail.setDeviceGroups(group);
    }

    if (obj.has("location")) {
      JSONObject location = obj.getJSONObject("location");
      NetmeraGeoLocation geoLocation = new NetmeraGeoLocation();
      double latitude = location.getDouble("latitude");
      double longitude = location.getDouble("longitude");
      geoLocation.setLatitude(latitude);
      geoLocation.setLongitude(longitude);
      deviceDetail.setDeviceLocation(geoLocation);
    }
    return deviceDetail;
  }
  public void getDeviceDetail(JSONArray array, CallbackContext callbackContext)
      throws JSONException {
    JSONObject deviceDetail = new JSONObject();

    NetmeraDeviceDetail netmeraDeviceDetail;
    try {
      netmeraDeviceDetail = NetmeraPushService.getDeviceDetail(Netmera.getContext());
    } catch (NetmeraException e) {
      callbackContext.error(jsonError(e));
      return;
    }
    List<String> deviceGroups = netmeraDeviceDetail.getDeviceGroups();

    if (deviceGroups.size() > 0) {
      JSONArray tagArray = new JSONArray();
      for (int i = 0; i < deviceGroups.size(); i++) {
        tagArray.put(deviceGroups.get(i));
      }
      deviceDetail.put("tags", tagArray);
    }

    NetmeraGeoLocation deviceLocation = netmeraDeviceDetail.getDeviceLocation();
    if (deviceLocation != null) {
      JSONObject location = new JSONObject();
      location.put("latitude", deviceLocation.getLatitude());
      location.put("longitude", deviceLocation.getLongitude());
      deviceDetail.put("location", location);
    }

    callbackContext.success(deviceDetail);
  }