Native platform interface

As we define the JavaScript interface of our plugin, we also need a Native implementation for each platform that the plugin supports. The following is a sample Java implementation for the Native Android platform:

    package com.eddyblue.plugin;import org.apache.cordova.*;import org.json.JSONArray;import org.json.JSONException;public class Scan extends CordovaPlugin {    @Override    public boolean execute(String action, JSONArray         data, CallbackContext callbackContext) throws         JSONException {        if (action.equals("start")) {            String message = "data to be sent";            callbackContext.success(message);            return true;        } else {            return false;        }    }}

We have now briefly covered how plugins work. You can now easily share your plugin with the ...

Get Hybrid Mobile Development with Ionic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.