Hello,
I’m angular+android developer and started to play with Ionic.
I googled and goolged but didn’t find any example how to do so. I saw PhoneGap but sounds like Cordova a bit different. Sadly, but from Ionic site I succeeded to run 2 demos where native side is empty and I have no clue how to do that.
Any links, examples…
[EDIT]
I grabbed some example from this site that works for me:
AlertBack.java
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;
import android.widget.Toast;
public class AlertBack extends CordovaPlugin {
@Override
public boolean execute(String action, JSONArray args,
CallbackContext callbackContext) throws JSONException {
if (action.equals("alertBack")) {
Toast.makeText(cordova.getActivity(), "Using Toast You Entered "+
args.getString(0), Toast.LENGTH_LONG).show();
callbackContext.success("Returning from native You Entered "
+ args.getString(0));
return true;
}
return false; // Returning false results in a "MethodNotFound" error.
}
}
res/xml/config.xml
...
<feature name="AlertBack">
<param name="android-package" value="com.oodles.plugin.AlertBack" />
</feature>
...
plugin.js
window.alertBack = function(str, callback) {
cordova.exec(callback, function(err) {
callback('Nothing to echo.');
}, "AlertBack", "alertBack", [str]);
};
implementation:
window.alertBack(userName, function(echoValue) {
alert(echoValue);
});
You can see that its JavaScript implementation. I’m looking for Angular way to rewrite plugin.js
and it’s call
Thank you