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!
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
Post not yet marked as solved
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?
Post not yet marked as solved
Please i have an iOS webview app I'd like to submit to appstore. Will this be possible
Post not yet marked as solved
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!
Post not yet marked as solved
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.
Post not yet marked as solved
On iOS 14 and lower, everything is fine.
Post not yet marked as solved
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
Post not yet marked as solved
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.
Post not yet marked as solved
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?
Post not yet marked as solved
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
Post not yet marked as solved
In iOS 15 beta 8, Safari/WKWebView is not loading some of the web pages it displays the blank white screen.
Is anyone facing the same problem in Safari browser or WKWebview? How to solve this issue, Please help me to move forward on this!!!
Post not yet marked as solved
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
Post not yet marked as solved
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.
Post not yet marked as solved
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.
Post not yet marked as solved
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
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.
Post not yet marked as solved
I am using WKWebView to run a react app inside my IOS app. I managed to turn off the experimental feature (NSURL Session WebSocket) of safari on the device's settings. But how do I do the same on code for WKWebView?
Post not yet marked as solved
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 .
Post not yet marked as solved
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.