Posts

Showing posts with the label wkwebview

Swipe gestures in WKWebView

Image
Clash Royale CLAN TAG #URR8PPP Swipe gestures in WKWebView So I have a WKWebView inside a UICollectionViewCell . I have to open few webpages but those webpages are eating up the scrolling by overriding touchmove event as below: WKWebView UICollectionViewCell touchmove document.addEventListener('touchmove', function(e) { e.preventDefault(); } I have tried adding swipe gestures to WKWebView and its superview . touchesMoved: is also not getting called inside superview. I cant disable userInteraction on webview as I want to be able to tap and interact with webview. WKWebView superview touchesMoved: userInteraction I tried overriding the existing touchmove event of webpage by injecting script: touchmove WKUserScript *script = [[WKUserScript alloc]initWithSource:@"window.ontouchmove = function() { window.webkit.messageHandlers.touchmoved.postMessage('Touches Moved..'); return true; ...

Is it possible to turn off location permission in WKWebView?

Image
Clash Royale CLAN TAG #URR8PPP Is it possible to turn off location permission in WKWebView? I am wondering if it is possible to stop WKWebView from showing the location permission prompt? ( "website.com" Would Like To Use Your Current Location ) I believe it is showing because the website contains a google map. I am not interested in preloading a location in its place like is shown in other SO questions. I simply don't want to use location in the WKWebView. Is there a way to stop the location permission prompt from appearing? I have tried injecting the following javascript but it doesn't work. let contentController = WKUserContentController() let scriptSource = "navigator.geolocation.getCurrentPosition = function(success, error, options) { // }; navigator.geolocation.watchPosition = function(success, error, options) { // }; navigator.geolocation.clearWatch = function(id) { // };" let script = WKUserScript(source: scriptSource, injecti...