stuyam / pressure

:point_down::boom: JavaScript library for handling Force Touch, 3D Touch, and Pointer Pressure.
https://pressurejs.com
MIT License
2.91k stars 98 forks source link

Cordova + WKWebView + UIWebView w/ pressure #29

Closed NorthMcCormick closed 8 years ago

NorthMcCormick commented 8 years ago

Looking into more of the cordova web view settings and seeing if there is anything I can find that would stop it, but it just returns the unsupported callback. I'd love to utilize this library in my hybrid app for a few things. Yours is the first library to include a callback like this so I wasn't sure if the other libs weren't working or if I was just crazy haha.

I'll do some digging and report back what I find, if anyone else has an idea of why the cordova web view (iOS 9, uses UIWebView same as safari) wouldn't work definitely chime in.


Please provide information about the device you are seeing the issue on Device is a iPhone 6S+ Operating system is iOS 9.1 Browser is UIWebView (not sure the versioning...)

stuyam commented 8 years ago

Hey @NorthMcCormick cool idea! Unfortunately from what I have noticed is that the UIWebView actually lags in support behind the actual Safari app. From my knowledge the web view does not support force values on touch events. That is why any other apps the use the web view like the chrome app do not support 3D touch.

I am going to double check on this but I am pretty sure that is why. Hopefully Apple will add support soon because that would be a big deal!

NorthMcCormick commented 8 years ago

I was afraid of that. I do know that the iOS 4.0+ platform version with cordova is giving us the option for and updated UIWebView as well as WKWebKit. So if we can leave this open, once I am able to get my project updated, I can test this with the WKWebKit. The newest chrome I think is using the new WKWebView as well. I'll double check that and maybe use it as a test bed too.

NorthMcCormick commented 8 years ago

I just confirmed, as of Chrome 48 (49 is the current production version) on iOS 9 and up pressureJS does work in the browser. So that's good news! Once I get the WKWebView working I can further test to see if it works without any further options.

stuyam commented 8 years ago

Oh that is great news! Thanks for doing that research, that is really good to know. So it sounds like it is supported in the WKWebView but not the UIWebView. I would love to know if you switch to the WKWebView if it will work. To be honest I did not know there were two different types of embedable web views on iOS.

NorthMcCormick commented 8 years ago

Yes, there are two, however the WKWebView has been bug-city for the last year or so. Cordova FINALLY has it supported with that 4.0 platform version.

In fact, it's been so buggy that (I'm pretty positive) iOS Safari didn't use WKWebView until iOS9, but it's been in the system since like iOS7, publicly available in iOS8.

Yeah cross my fingers it will work, it should open up some cool doors for hybrid apps.

yanniks commented 8 years ago

Apple introduced new JavaScript engines with iOS 4.3 . Since then, they were Safari only, 3rd party apps had to use the old classes, known as UIWebKit. Since iOS 8, WKWebKit is available which now offers the same classes Safari uses.

stuyam commented 8 years ago

Thanks everyone for the input on this. I made two small iOS apps to test in the simulator, one running the UIWebView and one running the WKWebView. As we suspected pressure and 3D touch WORK in WKWebView but NOT in UIWebView. So if anyone is looking to use pressure (or any 3D touch in general) in an iOS web view use WKWebView and not UIWebView.

:white_check_mark: WKWebView :x: UIWebView