Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.apache.cordova.plugin;
- import org.apache.cordova.CordovaPlugin;
- import org.apache.cordova.CallbackContext;
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
- /**
- * This class echoes a string called from JavaScript.
- */
- public class CDVEmarsys extends CordovaPlugin {
- @Override
- public void initialize(CordovaInterface cordova, CordovaWebView webView) {
- super.initialize(cordova, webView);
- MobileEngageConfig config = new MobileEngageConfig.Builder()
- .application(this)
- .credentials(<applicationCode: String>, <applicationPassword: String>)
- .statusListener(getStatusListener())
- //either enable or disable the SDK provided Oreo default channel
- //one must be chosen
- //.enableDefaultChannel("default name", "description for the default channel")
- //.disableDefaultChannel()
- .build();
- MobileEngage.setup(config);
- }
- @Override
- public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
- if (action.equals("register")) {
- String message = args.getString(0);
- this.register(message, callbackContext);
- return true;
- } else if (action.equals("pushtoken") {
- String message = args.getString(0);
- this.pushToken(message, callbackContext);
- return true;
- }
- return false;
- }
- private void register(String message, CallbackContext callbackContext) {
- if (message != null && message.length() > 0) {
- callbackContext.success(message);
- } else {
- callbackContext.error("Expected one non-empty string argument.");
- }
- }
- private void pushToken(String message, CallbackContext callbackContext){
- if (message != null && message.length() > 0) {
- callbackContext.success(message);
- } else {
- callbackContext.error("Expected one non-empty string argument.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement