I can expose JS interfaces through an object "native" by doing
webView.addJavascriptInterface(new MyJSInterface(), "native");
then JS can call native.someFunc(). However, I need to expose those interfaces in the form of com.myCompany.someFunc() to avoid changing server-side code. Current server-side code already consumes com.myCompany.someFunc() in non-Android platforms.
I'm wondering what'd be the best way to expose JS interfaces through a com.myCompany object?
I tried webView.addJavascriptInterface(new MyJSInterface(), "com.myCompany"); but it didn't work.
I can expose JS interfaces through object "native", then inject JS code to define an object "com.myCompany" with function someFunc() that delegates to native.someFunc(). I haven't tried this but it doesnt look clean anyway.
Is there a better way to do this? Thanks.
Aucun commentaire:
Enregistrer un commentaire