TruckMovers / cordova-plugin-remote-injection

DEPRECATED: Cordova plugin to allow a remote site to interact with cordova's javascript APIs when loaded within a cordova app.
Apache License 2.0
91 stars 95 forks source link

Support for wkwebview #8

Closed twang333 closed 8 years ago

bradleyjames commented 8 years ago

Can you please provide some details? Why is this beneficial, what will it provide you, etc.? Also links to relevant docs would be great.

bradleyjames commented 8 years ago

Without details I'm not sure what to do with this. If I had extra time I'd do some digging but I don't have it right now. If you have information on errors you're seeing, what platform, etc. it will give me some place to start.

Until then closing.

Klathmon commented 8 years ago

I'd like to +1 this request.

Starting with cordova 6 (I believe), Cordova has allowed the developer to switch out the rendering engine on ios. It can be switched from UIWebView to WKWebView.

WKWebView uses a much faster javascript engine, and has some other benefits, but has a different API. It's not a show-stopper that this plugin doesn't work with WKWebView, but having to fallback to UIWebView is making the whole application sluggish (it's a pretty javascript heavy application).

Currently this application does nothing when used with a WKWebView. I'm assuming it needs some changes to either use Cordova's "renderer independent" API, or it needs to be custom coded for WKWebView support.

bradleyjames commented 8 years ago

@Klathmon, thanks for the info. Reopening.

Klathmon commented 8 years ago

So I decided to take a crack at it. First time ever working with objective-c, and I managed to get something together for our internal usage.

I kind of went "scorched earth" on this and removed literally everything except for the bare minimum I needed, so this ONLY injects the cordova.js and plugin files into any remote app, and it ONLY works with WKWebView. The fork is located here.

It shouldn't be that tough at all to support both WKWebView and UIWebView at the same time. In case anyone else wants to pickup where I left off, I'm going to dump a few links I found useful.

bradleyjames commented 8 years ago

You just made my day, awesome work. I'm trying to block off a little time to get to this.

Klathmon commented 8 years ago

Like I said, I got it working enough that I'm happy, so don't feel like you need to rush for me!

bradleyjames commented 8 years ago

I believe I have this implemented in the branch issue-8. I have more testing to do but please check it out and see if it addresses your needs or if you run into issues.

This is a passive change and should auto detect the type of web view in use and react accordingly.

Klathmon commented 8 years ago

That works fantastically! Zero changes needed on my part, and I now have the full functionality with WkWebView.

Thanks a ton for following up on this!

bradleyjames commented 8 years ago

Glad it works for you. I'll get it merged into master and pushed to npm this week.

bradleyjames commented 8 years ago

This has been merged into mainline and is in the 0.4.0 release.