public JSONObject jsonNotification(String message, Map<String, String> extras) { JSONObject data = new JSONObject(); try { data.put("message", message); data.put("extras", new JSONObject(extras)); } catch (JSONException e) { Logging.error("NOTIFICATION", e.getMessage()); } return data; }
public boolean execute(String action, JSONArray data, CallbackContext callbackContext) { if (!knownActions.contains(action)) { Logging.debug("ACTION", "Invalid action: " + action); callbackContext.error(jsonError("Action is unknown", 5555)); return false; } try { Logging.debug("EXEC", "Plugin Execute: " + action); Method method = NetmeraPhoneGapPlugin.class.getDeclaredMethod( action, JSONArray.class, CallbackContext.class); method.invoke(this, data, callbackContext); return true; } catch (Exception e) { Logging.error("EXEC", e.getMessage(), e); callbackContext.error(jsonError("Method cannot be found", 5555)); } return false; }