Example usage for com.facebook.react.bridge WritableMap putString

List of usage examples for com.facebook.react.bridge WritableMap putString

Introduction

In this page you can find the example usage for com.facebook.react.bridge WritableMap putString.

Prototype

void putString(@NonNull String key, @Nullable String value);

Source Link

Usage

From source file:by.iba.gomel.avkhonia.MFReactNativeBind.GenericSecurityCheckChallengeHandler.java

License:Apache License

@Override
public void handleChallenge(JSONObject jsonObject) {
    isChallenged = true;//from  w  w  w  . j  ava 2  s.  c om
    WritableMap params = null;
    try {
        params = RNJSONUtils.convertJsonToMap(jsonObject);
        params.putString("securityCheck", Constants.SECURITY_CHECK);
        reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
        Log.d("IBATimesheet", "Handle challenge - LOGIN_REQUIRED event");
        sendEvent(reactApplicationContext, "LOGIN_REQUIRED", null);
    } catch (JSONException e) {
        Log.e("IBATimesheet", e.getMessage(), e);
    }
}

From source file:by.iba.gomel.avkhonia.MFReactNativeBind.GenericSecurityCheckChallengeHandler.java

License:Apache License

@Override
public void handleFailure(JSONObject jsonObject) {
    Log.d("IBATimesheet", "Handle failure");
    isChallenged = false;/*from ww  w  . j  a v a  2  s .  c  o m*/
    WritableMap params = null;
    try {
        params = RNJSONUtils.convertJsonToMap(jsonObject);
        params.putString("securityCheck", Constants.SECURITY_CHECK);
        if (!jsonObject.isNull("failure")) {
            params.putString("errorMsg", jsonObject.getString("failure"));
        } else {
            params.putString("errorMsg", "Unknown error");
        }
        reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
        sendEvent(reactApplicationContext, "LOGIN_FAILED", params);
    } catch (JSONException e) {
        Log.e(this.getClass().getCanonicalName(), e.getMessage(), e);
    }
}

From source file:by.iba.gomel.avkhonia.MFReactNativeBind.GenericSecurityCheckChallengeHandler.java

License:Apache License

public void login(JSONObject credentials) {
    Log.d("IBATimesheet", "Try to login");
    if (isChallenged) {
        submitChallengeAnswer(credentials);
    } else {//w  w w  . j  a va  2  s .  co  m
        WLAuthorizationManager.getInstance().login(Constants.SECURITY_CHECK, credentials,
                new WLLoginResponseListener() {
                    @Override
                    public void onSuccess() {
                        reactApplicationContext
                                .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
                        Log.d("IBATimesheet", "login - LOGIN_SUCCESS event");
                        sendEvent(reactApplicationContext, "LOGIN_SUCCESS", null);
                    }

                    @Override
                    public void onFailure(WLFailResponse wlFailResponse) {
                        WritableMap params = new WritableNativeMap();
                        params.putString("errorMsg", wlFailResponse.getErrorMsg());
                        Log.d("IBATimesheet",
                                "Connection failure: " + wlFailResponse.getErrorCode().getDescription() + ": "
                                        + wlFailResponse.getErrorMsg());
                        sendEvent(reactApplicationContext, "CONNECTION_ERROR", params);
                    }
                });
    }
}

From source file:by.iba.gomel.avkhonia.MFReactNativeBind.GenericSecurityCheckChallengeHandler.java

License:Apache License

public void logout() {
    Log.d("IBATimesheet", "Try to logout");
    WLAuthorizationManager.getInstance().logout(Constants.SECURITY_CHECK, new WLLogoutResponseListener() {
        @Override//from w  w w .j a  v a 2  s . c  om
        public void onSuccess() {
            reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
            sendEvent(reactApplicationContext, "LOGOUT_SUCCESS", null);
        }

        @Override
        public void onFailure(WLFailResponse wlFailResponse) {
            WritableMap params = new WritableNativeMap();
            params.putString("errorMsg", wlFailResponse.getErrorMsg());
            reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
            sendEvent(reactApplicationContext, "LOGOUT_FAILURE", null);
        }
    });
}

From source file:co.rewen.statex.AsyncStorageErrorUtil.java

License:Open Source License

/**
 * Create Error object to be passed back to the JS callback.
 *///  w  ww.j a v  a2s . c o  m
/* package */ static WritableMap getError(@Nullable String key, String errorMessage) {
    WritableMap errorMap = Arguments.createMap();
    errorMap.putString("message", errorMessage);
    if (key != null) {
        errorMap.putString("key", key);
    }
    return errorMap;
}

From source file:com.adjust.nativemodule.AdjustUtil.java

License:Open Source License

public static WritableMap attributionToMap(AdjustAttribution attribution) {
    WritableMap map = Arguments.createMap();

    if (null == attribution) {
        return map;
    }/*from w  w  w .ja  va2s  . c  o  m*/

    map.putString(ATTRIBUTION_TRACKER_TOKEN, null != attribution.trackerToken ? attribution.trackerToken : "");
    map.putString(ATTRIBUTION_TRACKER_NAME, null != attribution.trackerName ? attribution.trackerName : "");
    map.putString(ATTRIBUTION_NETWORK, null != attribution.network ? attribution.network : "");
    map.putString(ATTRIBUTION_CAMPAIGN, null != attribution.campaign ? attribution.campaign : "");
    map.putString(ATTRIBUTION_ADGROUP, null != attribution.adgroup ? attribution.adgroup : "");
    map.putString(ATTRIBUTION_CREATIVE, null != attribution.creative ? attribution.creative : "");
    map.putString(ATTRIBUTION_CLICK_LABEL, null != attribution.clickLabel ? attribution.clickLabel : "");
    map.putString(ATTRIBUTION_ADID, null != attribution.adid ? attribution.adid : "");

    return map;
}

From source file:com.adjust.nativemodule.AdjustUtil.java

License:Open Source License

public static WritableMap eventSuccessToMap(AdjustEventSuccess eventSuccess) {
    WritableMap map = Arguments.createMap();

    if (null == eventSuccess) {
        return map;
    }// ww w . j  a v  a2  s. c o  m

    map.putString(EVENT_SUCCESS_MESSAGE, null != eventSuccess.message ? eventSuccess.message : "");
    map.putString(EVENT_SUCCESS_TIMESTAMP, null != eventSuccess.timestamp ? eventSuccess.timestamp : "");
    map.putString(EVENT_SUCCESS_ADID, null != eventSuccess.adid ? eventSuccess.adid : "");
    map.putString(EVENT_SUCCESS_EVENT_TOKEN, null != eventSuccess.eventToken ? eventSuccess.eventToken : "");
    map.putString(EVENT_SUCCESS_JSON_RESPONSE,
            null != eventSuccess.jsonResponse ? eventSuccess.jsonResponse.toString() : "");

    return map;
}

From source file:com.adjust.nativemodule.AdjustUtil.java

License:Open Source License

public static WritableMap eventFailureToMap(AdjustEventFailure eventFailure) {
    WritableMap map = Arguments.createMap();

    if (null == eventFailure) {
        return map;
    }//w  w w. ja  va2  s .  c o  m

    map.putString(EVENT_FAILED_MESSAGE, null != eventFailure.message ? eventFailure.message : "");
    map.putString(EVENT_FAILED_TIMESTAMP, null != eventFailure.timestamp ? eventFailure.timestamp : "");
    map.putString(EVENT_FAILED_ADID, null != eventFailure.adid ? eventFailure.adid : "");
    map.putString(EVENT_FAILED_EVENT_TOKEN, null != eventFailure.eventToken ? eventFailure.eventToken : "");
    map.putString(EVENT_FAILED_WILL_RETRY, eventFailure.willRetry ? "true" : "false");
    map.putString(EVENT_FAILED_JSON_RESPONSE,
            null != eventFailure.jsonResponse ? eventFailure.jsonResponse.toString() : "");

    return map;
}

From source file:com.adjust.nativemodule.AdjustUtil.java

License:Open Source License

public static WritableMap sessionSuccessToMap(AdjustSessionSuccess sessionSuccess) {
    WritableMap map = Arguments.createMap();

    if (null == sessionSuccess) {
        return map;
    }//  w  ww  .  j  a va 2 s  .  co  m

    map.putString(SESSION_SUCCESS_MESSAGE, null != sessionSuccess.message ? sessionSuccess.message : "");
    map.putString(SESSION_SUCCESS_TIMESTAMP, null != sessionSuccess.timestamp ? sessionSuccess.timestamp : "");
    map.putString(SESSION_SUCCESS_ADID, null != sessionSuccess.adid ? sessionSuccess.adid : "");
    map.putString(SESSION_SUCCESS_JSON_RESPONSE,
            null != sessionSuccess.jsonResponse ? sessionSuccess.jsonResponse.toString() : "");

    return map;
}

From source file:com.adjust.nativemodule.AdjustUtil.java

License:Open Source License

public static WritableMap sessionFailureToMap(AdjustSessionFailure sessionFailure) {
    WritableMap map = Arguments.createMap();

    if (null == sessionFailure) {
        return map;
    }/*from ww w  .ja  va  2  s . co m*/

    map.putString(SESSION_FAILED_MESSAGE, null != sessionFailure.message ? sessionFailure.message : "");
    map.putString(SESSION_FAILED_TIMESTAMP, null != sessionFailure.timestamp ? sessionFailure.timestamp : "");
    map.putString(SESSION_FAILED_ADID, null != sessionFailure.adid ? sessionFailure.adid : "");
    map.putString(SESSION_FAILED_WILL_RETRY, sessionFailure.willRetry ? "true" : "false");
    map.putString(SESSION_FAILED_JSON_RESPONSE,
            null != sessionFailure.jsonResponse ? sessionFailure.jsonResponse.toString() : "");

    return map;
}