Questions tagged [wkwebview]

A WKWebView object displays interactive web content. It is provided by Apple's WebKit which is available for macOS, iOS and tvOS as well.

A WKWebView object displays interactive web content. It is provided by Apple's Open Source Project WebKit and is available for macOS, iOS and tvOS as well.

Links:

3852 questions
33
votes
7 answers

WKWebview - Complex communication between Javascript & native code

In WKWebView we can call ObjectiveC/swift code using webkit message handlers eg: webkit.messageHandlers..pushMessage(message) It works well for simple javascript functions without parameters. But; Is it possible to call native code with JS…
Clement Prem
  • 3,112
  • 2
  • 23
  • 43
33
votes
5 answers

JavaScript synchronous native communication to WKWebView

Is synchronous communication between JavaScript and Swift/Obj-C native code possible using the WKWebView? These are the approaches I have tried and have failed. Approach 1: Using script handlers WKWebView's new way of receiving JS messages is by…
paulvs
  • 11,963
  • 3
  • 41
  • 66
32
votes
3 answers

Get the current full URL for WKWebView

Is there a way to get the FULL URL loaded by a WKWebView for every request? webView:didFinishNavigation: Works only for mainFrame navigations and does not provide a URL request parameter. How do I get the FULL URL just like in…
i-konov
  • 842
  • 1
  • 7
  • 19
32
votes
5 answers

How to show the inspector within your WKWebView based desktop app?

I'm looking for a way to show the inspector for a WKWebView inside my Mac app. With WebKit1 and WebView it was easy to show the inspector inside your Mac app, by just setting WebKitDeveloperExtras to true in your UserDefaults. That would give you an…
Koen Bok
  • 3,234
  • 3
  • 29
  • 42
31
votes
2 answers

How to get JSContext from WKWebView

In UIWebView, I can get JSContext through: [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"] The same way doesn't work in WKWebView and app crashes when it arrives this line of code. Is there a way to get JSContext in…
Xiong
  • 333
  • 1
  • 3
  • 5
31
votes
10 answers

How to change WKWebView or UIWebView default font

What font does UIWebView and WKWebView use by default? I would like to be able to change that. But I don't want to do it in the html string, instead I want to have something like: // obj-c [webView setFont:[UIFont fontWithName:@"GothamRounded-Bold"…
Au Ris
  • 4,541
  • 2
  • 26
  • 53
30
votes
6 answers

make WKWebview "real" fullscreen on iPhone X (remove safe area from WKWebView

I'm trying to implement a "real" fullscreen in App WebView, meaning I want the webcontent to fully go under the notch no matter what. This is the current situation I am facing, when framing the WebView to the superviews bounds: The red border is…
j0h4nn3s
  • 2,016
  • 2
  • 20
  • 35
30
votes
5 answers

WKWebView not rendering correctly in iOS 10

I have WKWebView inside the UITableViewCell. The web view load request and then after finished loading, I'll resize the web view height to be equal to its content height, then adjust table view cell height to fit accordingly. What happened was the…
wint
  • 1,266
  • 2
  • 14
  • 28
29
votes
5 answers

How to play video inline with WkWebView

When you use an iphone and play video in a webview, this video is open in the native player in fullscreen. We have tried UIWebView and WKWebView with "allowsInlineMediaPlayback" property to true. But the video in the web content launch in fullscreen…
UBLearn
  • 291
  • 1
  • 3
  • 4
29
votes
1 answer

WKWebView and window.open

It appears that a lot of links on websites use window.open in their onclick handlers but WKWebView seems to completely ignore window.open. Is there a workaround for this? I tried setting javaScriptCanOpenWindowsAutomatically preference to true but…
Bret
  • 883
  • 1
  • 9
  • 18
29
votes
7 answers

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,…
Mattias Farnemyhr
  • 4,148
  • 3
  • 28
  • 49
28
votes
6 answers

Set WKWebViewConfiguration on WKWebView from Nib or Storyboard

With iOS 11 Apple has added the ability set add WKWebViews outlets on your nibs and storyboards. It seems to work fine when using the default WKWebViewConfiguration that get set automatically. However, I'd like to be able to use a custom…
Matt.M
  • 1,039
  • 3
  • 14
  • 21
28
votes
0 answers

How to read a blob data URL in WKWebView?

I have a WKWebView, but when I click on a link that has the following URL: blob:https://www.mycase.com/2963c6c0-24c1-418f-a314-88f7a2dbc713 Nothing happens. Reading the documentation it describes: The only way to read content from a Blob is to use…
Mark
  • 16,906
  • 20
  • 84
  • 117
28
votes
6 answers

how can I clear the contents of a UIWebView/WKWebView?

I have a webview that can be cycled through different URLs. When I switch from one to the other I want the old web page to disappear before loading the next one. How can I do this without re allocating the webview? If I try to [self.webView…
Halpo
  • 2,982
  • 3
  • 25
  • 54
27
votes
3 answers

Authentication with WKWebView in Swift

In my iOS app, I would like to use a WKWebView to wrap an external URL in the application. This URL requires basic authentication (it needs user and password credential, like in the following screenshot). After some investigation, I'm trying to use…
giograno
  • 1,749
  • 3
  • 18
  • 30