Ask away

NEST app receive event in the NEST IDE

Richard 12/04/17 09:32

20 views

Question CategoryGeneral

Number of completed projects0

Question StatusUnsolved

  • event
  • nest ide

Question

I am new to NEST app and looking on how to capture events fired from JS components in my NEST app while using IDE. Say I receive events in that interface how do I differentiate events so I will handle each appropriately? Looking for some guides or reference project file which will help me get started

Answers

1
Joachim 12/07/17 11:39

you need to implement a component plugin by using Java- code public class CustomPlugin extends CordovaPlugin { @Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { if (action.equals("sayHello")){ try { String responseText = "Hello world, " + args.getString(0); callbackContext.success(responseText); } catch (JSONException e){ callbackContext.error("Failed to parse parameters"); } return true; } return false; } } Finally, we calling a plugin from javascript function initial(){ var name = $("#NameInput").val(); cordova.exec(sayHelloSuccess, sayHelloFailure, "CustomPlugin", "sayHello", [name]); } function sayHelloSuccess(data){ alert("OK: " + data); } function sayHelloFailure(data){ alert("FAIL: " + data); }

Answer

Project

Image

Comment