コード例 #1
0
  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);
  }
コード例 #2
0
  public void initialize(JSONArray params, CallbackContext callbackContext) throws JSONException {
    Context context = this.cordova.getActivity().getApplicationContext();

    String apiKey = params.getString(0);
    String senderId = params.getString(1);

    Netmera.init(context, apiKey);
    senderID = senderId;
    callbackContext.success();
  }