Explore WKWebView additions

RSS for tag

Discuss the WWDC21 session Explore WKWebView additions.

View Session

Posts under wwdc21-10032 tag

68 Posts
Sort by:
Post marked as solved
1 Replies
1.1k Views
In the session, regarding prompting user for camera or microphone permission, the delegate method shown in the code snippet is the following: func webView(_ webView: WKWebView, decideMediaCapturePermissionFor origin: WKSecurityOrigin, initiatedByFrame frame: WKFrameInfo, type: WKMediaCaptureType) async -> WKPermissionDecision { return type == .microphone ? .prompt : .deny } But, I couldn't find this method in the documentation. Instead, I found this: func webView(_ webView: WKWebView, requestMediaCapturePermissionFor origin: WKSecurityOrigin, initiatedByFrame frame: WKFrameInfo, type: WKMediaCaptureType, decisionHandler: @escaping (WKPermissionDecision) -> Void) Which one is the latest? Thanks!
Posted
by
Post marked as solved
1 Replies
799 Views
I have iOS application which has WebSocket communication between Xcode libraries and WKWebView (Java script) front end UI. client usually sends 200 bytes. however on demand, it may send upto 2MB encrypted binary data messages. In iOS 14, server (Java script) was able to receive 2 MB of binary message. In iOS 15 Beta 1 & 2, not able receive message beyond 500 KB. Do I need to tune any properties to receive 2 MB data ? , is there any relation between this issue and com.apple.developer.kernel.increased-memory-limit entitlements
Posted
by
Post not yet marked as solved
0 Replies
418 Views
I am printing the contents rendered on a WKWebView using this API. https://developer.apple.com/documentation/webkit/wkwebview/3516861-printoperationwithprintinfo?language=objc The print preview loads fine, but I am unable to print page numbers. I tried overriding the drawPageBorderWithSize method of NSView (since WKWebView inherits from NSView) but that never gets called. I asked a question in the Apple Developer Technical Support and I was asked to use CSS styling to print page numbers. I then tried to use the following solution in CSS: #content { display: table; } #pageFooter { display: table-footer-group; } #pageFooter:after { counter-increment: page; content: counter(page); } <div id="content"> <div id="pageFooter">Page </div> multi-page content here... </div> However, when I try this I only get Page1 at the bottom of the last page. Are there any working solutions for printing page numbers using CSS styling?
Posted
by
Post not yet marked as solved
0 Replies
342 Views
Please i have an iOS webview app I'd like to submit to appstore. Will this be possible
Posted
by
Post not yet marked as solved
4 Replies
1.7k Views
We call webView evaluateJavaScript:javaScript completionHandler:^(id _Nullable result, NSError *_Nullable error) API to inject a javascript to WKWebView. The javascript contains "window.***"definition. Since iOS 15, "window.***" can not be found and it will return "undefined" when accessing "window.***" . It seems that javascript "window" object can not have any custom sub-object. However same javascript code works fine on iOS 14.x and below. Any ideas? Thanks!
Posted
by
Post not yet marked as solved
0 Replies
258 Views
I am trying to load HTML along with JavaScript file from the assets folder using "webview_flutter" plugin. On the webview loading page I am getting this error I have also added "NSAppTransportSecurity" permissions to the Info.plist file and changed the iOS deployment target version to 11.0, 12.0. But still not working any solution.
Posted
by
Post not yet marked as solved
7 Replies
2k Views
First, thank you for adding getUserMedia to WKWebview. Now, I have a webrtc session with audio and video going both directions, problem is that when the app goes to background I can only hear the incoming audio on the iPhone side, but the mic audio is not being sent from the iPhone to the remote side. Using the new iOS 15 API I can see that wkwebview.microphoneCaptureState becomes muted shortly after applicationDidEnterBackground (using wkwebview.setMicrophoneCaptureState to active doesn't help when in the background either). I see this issue in iOS 15 beta 8 and also in iOS 14.7. If using the native mic capture with AVAudioSession then the mic continues to work in the background, so I background modes are good. Is there some config I can set to continue having the mic working in the background? Thank you
Posted
by
Post not yet marked as solved
0 Replies
245 Views
Hi there, I am currently working on a small MacOS status bar app that involves running a local ReactJS app within a WKWebView. For the most part communication between Swift and React is accomplished via evaluateJavaScript / userContentController handler/listeners, but in some instances, I am using fetch GET/POST requests within the React app to retrieve data from an API I am serving elsewhere. The problem I am running into is when I make an HTTP GET request within the React app to retrieve some data from my server, I can see it reaching the endpoint, however the response in React is never fulfilled. When testing this in React alone in a web browser it works fine, which leads me to believe this is a security issue with WKWebView or a greater extent the app. I've tried numerous NSAppTransport settings to no avail. Any thoughts on this issue would be greatly appreciated.
Posted
by
Post not yet marked as solved
0 Replies
413 Views
For iOS 14.3 apple announced WebRTC support for WKWebViews. For iOS 15, extension in such support was announced. I have loaded a WebView in both, iOS 14.5 and iOS 15 and observed different behaviors. Things do not work for either iOS. My website, requires access to the microphone. When I load it for iOS 14.5, and click on the microphone, the app crashes with a memory exception (Malloc) for webkit userPermissionRequestProxy. When I use iOS 15, no error or crash occurs, yet the microphone is not working. I have updated the info.plist file to allow permissions I am giving access to AVAudioSession. Is there anything else I need to do?
Posted
by
Post not yet marked as solved
0 Replies
322 Views
WKWebView keyboard suggestions not showing for email field/username field. We tried the autocomplete attribute - ‘username’ in the HTML page content.  The HTML page has the following code for the above - input id="user-text-field" type="email" autocomplete="username We are currently using iPhone7 with iOS version 14.4, and iPhone X with 14.5 iOS version. Any help would be greatly appreciated. Thank you
Posted
by
Post not yet marked as solved
0 Replies
550 Views
I have an iOS webview app which require access to third party cookies accessed from inside an iFrame, even if I clear the Prevent Cross Site Tracking on IPhone Safari Settings, it does not work! But when I access the webview link directly using Safari (Desktop) and clear the Prevent Cross-Site Tracking, it works fine! I have been trying for over a week now, and no luck I have added NSCrossWebsiteTrackingUsageDescription to the info.plist on the iOS app and I can see the new settings for the app, but even if I allow cross-site tracking, still does not work! I have also added WKAppBoundDomains to the info.plist as an array with different combination as below: thirdparty.com, *.thirdparty.com, a.thirdparty.com, a.b.thirdparty.com with no luck either! I have been searching SO, Apple Forum and webkit for many days, seems some people have it working but i have no clue how did they get it to work as there were no clear solutions? I am not sure why Safari (Desktop) behaves in a different manner to Safari (Mobile)! I have tried on simulator and an iphone device, cleared all data and website cookies, still not working. If you have successfully implemented WkAppBoundDomains or NSCrossWebsiteTrackingUsageDescription, please share your solution as I am out of ideas. Your time is greatly appreciated Xcode: 12, iOS: 14
Posted
by
Post not yet marked as solved
0 Replies
223 Views
I am displaying this contact form inside my webview but when I click on the bottom most text area it focuses on it and moves the point of view into the center ( I think this is a normal / desirable behavior ) But after the keyboard hides it remains like that thus creating a white space on the bottom part and It will get stuck into this state unless I click the top most input text. I checked this behavior on IOS 14 and it seems like it got fixed. But I am just wondering how to get around this on IOS 13.
Posted
by
Post not yet marked as solved
0 Replies
172 Views
Below is my code: let loginButton = "document.getElementById('loginButton').click()" webView.evaluateJavaScript(loginButton) { result, error in print(result, error) } It works fine when the device has internet. But before calling this func, I turn off the internet, the func is called but nothing returned. Can I set a timeout for this func or get a callback error from anything to know there is an error. Thanks.
Posted
by
Post not yet marked as solved
0 Replies
215 Views
Hello Apple Team, As described in the subject and from the attached screenshot we are not seeing the labels, icons, and selected date in the date picker for iOS version 14.0 and above. We are using WKWebview to load the forms, using HTML tag input type="date"> to show the date picker. Environment Details: xCode version 12.4 Swift version 5.0. The app is developed in native iOS. We tried different ways to fix this issue but to no avail. Guide us to fix this, as it is a production issue. Let us know for any other clarifications, waiting for your response ASAP.
Post not yet marked as solved
1 Replies
282 Views
javaScriptCanOpenWindowsAutomatically feature is available with WKPreferences As WKPreferences.javaScriptEnabled got deprecated, it is recommended to migrate with WKWebpagePreferences . But as the dependent javaScriptCanOpenWindowsAutomatically is not available in WKWebpagePreferences blocking our functionality.
Posted
by
Post not yet marked as solved
2 Replies
1.7k Views
func loadURL(_ request: URLRequest) {         navigationDelegate = self         uiDelegate = self         load(request)         scrollView.delegate = self     }          func loadURL(_ path: String) {         navigationDelegate = self         uiDelegate = self                  let url = URL(fileURLWithPath: path)         let data = try! Data(contentsOf: url)         let baseURL = url.deletingLastPathComponent()                  load(data, mimeType: "application/pdf", characterEncodingName: "", baseURL: baseURL)                  scrollView.delegate = self     } } extension ProdWebView: WKNavigationDelegate {          func webView(_ webView: WKWebView,                  didStartProvisionalNavigation navigation: WKNavigation!)     {         webViewDelegate?.start()     }          func webView(_ webView: WKWebView,                  didFailProvisionalNavigation navigation: WKNavigation!,                  withError error: Error)     {         trace?.stop()         webViewDelegate?.error(error)     }          func webView(_ webView: WKWebView,                  didFinish navigation: WKNavigation!)     {         trace?.stop()         webViewDelegate?.stop()     } When user click on The Links double times .... I am getting crash I can see in auto logs code = -999 error 2021-10-03 21:04:43.113096+0530 eTradeMX[22419:6003510] [Process] 0x1070a1818 - [pageProxyID=5, webPageID=6, PID=22420] WebPageProxy::didFailProvisionalLoadForFrame: frameID = 3, domain = NSURLErrorDomain, code = -999 But below delegate method is not calling . Some times its calling some Times not calling . I was written delegates also   weak open var navigationDelegate: WKNavigationDelegate?     weak open var uiDelegate: WKUIDelegate?     navigationDelegate = self     uiDelegate = self   func webView(_ webView: WKWebView,          didStartProvisionalNavigation navigation: WKNavigation!) expect this didStartProvisionalNavigation remaining delegates are calling properly .
Posted
by
Post not yet marked as solved
0 Replies
188 Views
Hi, I am using WKWebView to showing some web content to user in my application. it is working fine for valid url. but when I try to load a request for invalid url it's show an empty view and getting an error in didFailProvisionalNavigation delegate method. but in other side SFSafariViewController shows an error message for invalid url. like "Safari cannot open the page because the server cannot found" is it any configuration/api for WKWebView so we can achieve the same behaviour like SFSafariViewController for invalid url? means, show the error message instead of blank screen.
Posted
by