Questions tagged [wkwebview]

0

votes
0

answer
4

Views

New window not showing up in WKWebView

I've got an application which is pulling in our website into a WKWebView, one of the webpages displays a new webpage from javascript using Window.Open();. This is where my issue comes in, the new window doesn't display. Below is my class which I'm using to initialize the Webview import UIKit import...
Demonic218
0

votes
0

answer
4

Views

Cordova iOS - WkWebView offline

Application cache is deprecated which means we'll need to switch to service worker but I've done research it was mentioned.. 1) "It is not possible to use a ServiceWorker in a Cordova app because the ServiceWorker API is not available to WKWebView and is not implemented in UIWebView. It is available...
y-dolem
1

votes
1

answer
1.1k

Views

javascript bridge in WKWebView doesn't work

I try to get javascript message from my Web View with WKWebView. But nothing appear inside IOS console... I implement this code: - (void) webView:(WKWebView *)webView didFailLoadWithError:(NSError *)error { self.webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 20, self.view.frame.size.width,...
Thomas Dupont
3

votes
0

answer
56

Views

WKNavigationResponse allHeaderFields does not contain JSESSIONID on iOS 12

I use WKWebView to handle login process of my application. I need to sync cookies between WKWebView and HTTCookieStorage. After each navigation response, I've migrated JSESSIONID cookie from WKWebView to HTTPCookieStorage. My code works on simulator and iOS 11 devices. But on iOS 12 devices, allHead...
fthdgn
1

votes
1

answer
942

Views

Enable cross-site tracking in WKWebView

When compiling against the iOS 11 SDK, it seems as though the default cookie accept policy for WKWebView has changed, as though the user had enabled the equivalent "Prevent Cross-Site Tracking" option in Safari. I need cross-site cookies to work within a WKWebView. Does anyone know of a way to enabl...
Andrew Ebling
1

votes
1

answer
542

Views

WKWebView observe cookies changes

According to wwdc 17 there is a way to observe cookies changes in WKWebView in iOs 11 (WebsiteDataStore.httpCookieStore). Could you provide example how to do that? I found that there is WKHTTPCookieStoreObserver and it has cookiesDidChange member. So i put that protocol as following class Activities...
dskibin
1

votes
2

answer
282

Views

Safari App Extension: WKWebKit in Popover not loading content

The objective To implement a Safari App Extension that shows a popover with a WebView inside that shows a webpage. The problem The popover shows up correctly in Safari, clicking on it brings up a blank popover with nothing in it. Based on logs in Console, the viewDidLoad() message shows up correctly...
msharp
1

votes
1

answer
70

Views

Force WKWebView to show desktop version

I have a NSViewController which displays various WKWebView at specific locations inside a NSView. If the frame of the WKWebView gets small - it switches to the mobile version of the website. Is there a way to always show the full (desktop version) website in the WKWebView? My first idea was to inje...
nor0x
0

votes
0

answer
15

Views

Load local html files from applications's document directory swift wkwebview

I am trying to load a local html file which is downloaded to my application with wkwebview. Along with this html file i am downloading two js files, they are referenced inside the html file. But what ever i do, they are not loading in wkwebview @IBOutlet var webView: WKWebView! @IBOutlet var act:...
milsha
0

votes
0

answer
3

Views

Scrolling programatically in MKWebView

I'm trying to scroll through pages in a WKWebView using the contentOffset approach webView.scrollView.contentOffset = CGPoint(x: 0, y: offset) This successfully moves the already displayed content - but what I need is to page down through the webpage content - just the same as when you physically sc...
Russell
0

votes
0

answer
3

Views

Xamarin.Forms 3.3 WKWebView inject javascript

I have followed this link Xamarin.Forms WKWebView to inject Javascript into WebView for iOS. It has worked until Xamarin.Forms 3.3. In Xamarin.Forms 3.3, the default custom renderer for iOS can be changed from UIWebView to WKWebView. I have followed the changes in AssemblyInfo.cs. Xamarin.Forms 3....
Tek Mun
0

votes
0

answer
5

Views

When I implement the decidePolicyForNavigationAction delegate methond,the Post request will be invalid in WKWebView

my system version is iOS 11.2.6 but i think in higher version have the same appearance. i post a request in wkwebview like this and it works fine NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:self.url]]; request.HTTPMethod = @"POST"; request.HTTPBody = [post...
uJumpDD
1

votes
1

answer
3.4k

Views

WKWebView and authentication

I'm trying to get authentication to work with my WKWebView with no success. I've tried the the usual methods i.e setting the credentials in the shared storage (How to do authentication in UIWebView properly?), using a NSURLConnection to catch the authentication challenge (How to display the Authenti...
Johan
1

votes
2

answer
1.2k

Views

WKWebview does not loading local image in Swift

i am using WKWebview to show my local htm file. Everything was good, but when i added local picture to my htm files, pictures didn't seem. Lots of stackoverflow user had similar problem but there is no clear answer. here is my code ; var a = dic["adi"]?.asString() var path = NSBundle.mainBundle().pa...
ardacankaya
1

votes
1

answer
4.6k

Views

Enable Javascript in WKWebView iOS 9

I was successfully using a WKWebView to load a url in iOS 8 using Xcode 6.4. I've upgraded to Xcode 7 and now the my WKWebView does not have Javascript enabled any longer. How do I enable Javascript in my WebView again?
somas1
1

votes
3

answer
1.8k

Views

Load desktop version WKWebView iOS 9

Up until recently let url = NSURL (string:http://asite.com) let request = NSMutableURLRequest(URL: url!) //iOS loads the mobile version of asite.com which does not have the required DOM so we force the desktop version by setting new value forHTTPHeadrField let newUserAgent = "Mozil...
RyanTCB
0

votes
1

answer
13

Views

Where is this toolbar coming from in iOS

I'm working with a webview, the current page has a form on it, and it seems that this toolbar is popping up at the bottom to let me switch between the different text fields in this view. What I can't figure out is what to even call this toolbar to see if there's a method to hide it. So basically, w...
Brent
0

votes
0

answer
5

Views

Adding WKWebView Programmatically

I am a beginner in iOS development and I have been having difficulty adding WKWebview with code. I intend to make it full width too but I get an empty screen. var webView = WKWebView() override func viewDidLoad() { super.viewDidLoad() self.view.addSubview(self.activityIndicatorView.getViewActivityIn...
bennycodest
0

votes
0

answer
3

Views

UIWebView and URLRequest Interception

I am trying to understand the request interception problem in UIWebView so I can start looking into WKWebView. What I don't understand is, UIWebView has its own method for interception which is shouldStartLoadWithRequest, but it seems like most of people are still implementing a custom NSURLProtocol...
Anna
10

votes
3

answer
320

Views

How to inject JavaScript callback to detect onclick event, using iOS WKWebView?

I'm using a WKWebView to show a website which has some HTML that includes three buttons. I want to run some Swift code in the native app when a specific button is clicked. About the HTML The three buttons look like this: The GotoURL function they call looks like this: function GotoURL(site) { if (si...
Aaron Brager
2

votes
0

answer
372

Views

Javascript Injection Not working on WKWebview on Device, but is working on Simulator

We need to set a cookie locally to the application that applies to our webview. We referenced this post. All we need is to inject a cookie. When running on the simulator everything works perfect, but when using a device the cookie fails to inject. This is the code we have so far. let userContentCont...
Sean Wilson
3

votes
2

answer
4.6k

Views

How to autoscale the contents of a WKWebView?

To autoscale a webpage inside a good old WebView in Swift, all I had to do was: var w:UIWebView w.scalesPageToFit=true I cannot find an equivalent method for a WKWebView, and webpages appear too big in my app. How can I autoscale the contents of a WKWebView? -I am using Xcode 7 and Swift
Josh
3

votes
3

answer
4.2k

Views

Unable to add WKWebView to Xcode Project

I have a ViewController that looks something like: import UIKit import WebKit class ViewController: UIViewController { @IBOutlet var webView: WKWebView! } In my storyboard I have a WKWebView as a subview of my main view. I've linked up the IBOutlet but when I run the application I receive: EXC_BAD_...
Kyle Decot
3

votes
1

answer
1.3k

Views

AngularJS send message to iOS WKWebView

I'm running a local webserver in my iOS App that serves an AngularJS app but I don't know how to communicate between the WKWebView and my controller. In iOS, viewDidLoad WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init]; [wkWebConfig.userContentController addScriptMessageHa...
11

votes
3

answer
5k

Views

Does webKit in iOS 11 (Beta) support WebRTC?

I have a URL that is working fine with Safari on iOS11 (Beta) Audio/Video is working fine. But when I load this URL with WKWebView it gives me an error "Incompatible Browser" and when I check my browser version in WebKit it shows "WebKit based browser on iOS 11" So the question really is, has Appl...
Adarsh Kumar
1

votes
3

answer
1.6k

Views

using KVO to observe WKWebView's URL property not work in iOS 10

I use WKWebView to load my webpage. When user click a button in webpage, my webpage will open a custom schema URL (e.g. asfle://download?media_id=1). And I use KVO to observe WKWebView's URL property to get the URL. It works well in iOS 9, but it doesn't work in iOS 10. I can't get the url. I use X...
Han Pengbo
1

votes
3

answer
1.5k

Views

Wait for JS Callback After evaluateJavaScript

I am trying to wait for javascript callback, however, the swift callback is being called before the javascript callback. How can I wait for JS callback? AppWebView.evaluateJavaScript("$('.loading-gif').removeClass('hide', function() { return true } );") { (Any, Error) in \\ .loading-gif successfully...
mTuran
2

votes
1

answer
58

Views

Inject JavaScript callback to detect onclick, using iOS WKWebView

I'm using a WKWebView to show a website which has some HTML that includes three buttons. I want to run some Swift code in the native app when a specific button is clicked. About the HTML The three buttons look like this: The GotoURL function they call looks like this: function GotoURL(site) { if (si...
Aaron Brager
0

votes
0

answer
9

Views

How to create custom X close button for a webview in Swift?

I need to create a custom close button for my webview that looks as w white X with a shadow. Something like this: It's not a problem for me to create something like this using just a regular letter "X", but in order to get exactly the same "X" I need to use emoji. I've already tried this: let button...
Boris
2

votes
0

answer
433

Views

Memory leak in WkWebView instantiation

I have a Viewcontroller which contains wkwebview when I pop it from the navigation controller I get memory leak The stack trace leads WkWebview instantiation I am not using any delegates as well. I am really wondering what causes this and how to fix this
Durai Amuthan.H
5

votes
4

answer
1.9k

Views

WKWebView not loading webpage - renders blank screen in Swift

This code is supposed to load the Apple homepage, but instead shows a blank screen. This happens with both HTTP and HTTPS URLs. Code: import UIKit import WebKit class WebViewController: UIViewController, WKUIDelegate{ var webView: WKWebView! override func loadView() { let webConfiguration = WKWebVi...
3

votes
1

answer
7.2k

Views

iOS WKWebView Swift javascript enable

I'm trying to develop a simple app to browse my website. However my website contains some javascript and it doesn't successfully show my website. In the past develop with android the same app and had to activate like this: webSettings.setJavaScriptEnabled(true); This currently my code I just have m...
lusito92
1

votes
1

answer
217

Views

iOS WebKit - DataCloneError: The object can not be cloned

When working with WKWebView of iOS WebKit, I encountered an error when I tried to postMessage back to my WKScriptMessageHandler in a code like window.webkit.messageHandlers.thisHandler.postMessage(message); where message is a Javascript object (or in iOS developer's eyes, a dictionary) and the error...
CodeBrew
2

votes
1

answer
883

Views

UI Webview or WK Webview

In my app, I want to open a website. Earlier I used UIWebview in Swift 3.0 and it was all good. But as I read that WKWebview should be used now, with WKWebview the website does not show in the app. I am confused that what can be the reason that why website works with UIWebview but not with WKWebview...
Waleed Asif
16

votes
10

answer
16.8k

Views

How to delete WKWebview cookies

For now I am doing like this NSHTTPCookie *cookie; NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; for (cookie in [storage cookies]) { [storage deleteCookie:cookie]; } But it is not working on iOS 8, 64-bit device. Any other way the clean cookies of WKWebview? Any help...
Pankaj Gaikar
16

votes
3

answer
18.4k

Views

WKWebView Estimated Progress

I'm trying to implement Estimated Progress in my WKWebView but can't seem to figure it out. Can you help? Here's what I've got: self.view = self.webView; NSURL *url = [NSURL URLWithString:stringWeb]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; WKWebViewConfiguration *configuration =...
Realinstomp
17

votes
3

answer
376

Views

WKWebView crashes if user answers an incoming iMessage

My apps have a significant crash - CALayer position contains NaN: [377.833 nan] with the following stack - Fatal Exception: CALayerInvalidGeometry 0 CoreFoundation 0x18283afe0 __exceptionPreprocess 1 libobjc.A.dylib 0x18129c538 objc_exception_throw 2 CoreFoundation...
shannoga
17

votes
9

answer
4.2k

Views

Disable entire UIMenuController edit menu in WKWebView

Requirement I have a WKWebView and would like to remove the system menu items (Copy, Define, Share...) from the Edit Menu and present my own. I am targeting iOS 8 and 9. I am currently testing with the Xcode 7.0.1 simulator (iOS 9) and my iPhone 6 running iOS 9.0.2. Standard Method Does Not Work I...
davew
17

votes
6

answer
16.4k

Views

Allow unverified ssl certificates in WKWebView

I'm trying to load a HTTPS url with an self-signed certificate in a WKWebView for iOS 8 and it keeps failing. The workaround used with UIWebView (using setAllowsAnyHTTPSCertificate from NSUrlRequest) doesn't seem to work. Does anyone know of any workaround? I do not need a solution that is valid f...
Roi
17

votes
8

answer
20.6k

Views

Can't set headers on my WKWebView POST request

I want to do a POST request to my WKWebView but the headers doesn't get set when I monitor the requests with Charles so the request fails. What is wrong here? NSString *post = [NSString stringWithFormat: @"email=%@&password=%@", email, password]; NSData *postData = [post dataUsingEncoding:NSASCIIStr...
Mattias Eriksson

View additional questions