I'm working on a wrapper for a web application that will run on android and on ios. I have created a simple native interface as so:
in my WebView I have included:
addJavascriptInterface(new MyNativeJsIface(mContext), NATIVE_IFACE_JSNAME);
in the init() method.
I proceeded to implement the interface and added the following line to a test html I am using for development:
var myNativeCallIface = window.nativeIface;
and then I am able to call my methods that I defined in my api successfully from the html like so:
alert("response from native:" + nativeIface.method1() );
So far so good right?
Wrong...
The problem I'm facing is that I'm not going to be able to load this code into the html of the web application itself, and I will therefore require a way to provide that interface to the developers of the web application without actually changing their code.
What I'd like to do is to make this code available so that when the application is running on android it will load the android js code and when it's running on ios it will load the ios js implementation (using the same method signatures) and I won't need to write a wrapper around the methods to check the user agent and act accordingly.
Is this possible? Am I going about this all wrong?