Post not yet marked as solved
Hello, my radio streaming app worked well in iOS 17.2 and earlier but from iOS 17.4 streaming no longer works, what has changed? What do I have to do in my app?
import UIKit
import WebKit
class ViewController: UIViewController, WKNavigationDelegate {
@IBOutlet weak var mWebView: WKWebView!
private let url: URL = URL(string: "https://mi web")!
override func viewDidLoad() {
super.viewDidLoad()
let configuration = WKWebViewConfiguration()
// Configurar preferencias de la página web
let preferences = WKPreferences()
preferences.javaScriptEnabled = true
configuration.preferences = preferences
mWebView.navigationDelegate = self
mWebView.load(URLRequest(url: url))
}
}
Post not yet marked as solved
Even when iOS's '"." Shortcut' keyboard setting is enabled, double-tapping the spacebar in WKWebView doesn't insert a period.
While making WKWebView editable , "." shortcut is not working. It works fine when any other external keyboard is used. I am facing this issue in WKWebView using apple keyboard. Even forceful adding javascript to replace double tap of space bar to period character logic is not working.
Post not yet marked as solved
I am embedding WKWebView in my macOS application and need to automate entering text and clicking form buttons on a webpage. I tried using selenium and it doesn't support WKWebView, it can only create a new Safari instance. What are my options?
Post not yet marked as solved
Problem:
Hello! I have some problems with UIEditMenuInteraction in WKWebView which show PDF using PDFKit (as far as I know) - when text is selected, there is no copy/paste buttons on iOS 16.4 or higher. Also I've noticed that selection blue view take less space than actual text is on iOS 17. The problem both cyrillic and latin characters.
How I can fix this?
p.s. I found on stackoverflow that PDFKit can treat PDF files like images, but on view hierarchy there is no differences between 16 and 17 iOS
How it looks:
The problem file:
https://drive.google.com/file/d/1Tu8RCrlwOI_H3TcwOGFbDR0G9h1OP7MU/view?usp=sharing
Post not yet marked as solved
After upgrading to ios17.4, webview app cannot access localstorage
Post not yet marked as solved
In Android there's a helpful feature in webview to load local files in assets folder as https to comply with same origin content policy (https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader)
Is there anything equivalent in WKWebView? I've been looking it up for a while and couldn't find anything conclusive. Thank you.
Post not yet marked as solved
Since the release of Xcode 15, my tests aren't functioning on Xcode Cloud. The login screen, which is a web view, isn't loading correctly during the Xcode Cloud UI tests, as depicted in the screenshot below:
Any insights on what might be causing this error? We haven't made any changes to this feature, and it operates smoothly locally.
Post not yet marked as solved
I'm migrating a macOS application from the old and deprecated WebView to the new and sparkly WKWebView. It seems to work fine, but four error messages appear in the console (see below) just after the dialog is closed.
I searched. It seems this issue can be fixed through the addition of a target entitlement called Background Modes. This particular capability is however not listed by Xcode, so I can't add it. I think this is because we're targeting macOS and not iOS, but I'm not certain.
Stuck. Tips and advice appreciated!
Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>
0x2c40246c0 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'WebProcess NearSuspended Assertion' for process with PID=66538, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}
Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>
0x2c4024720 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'GPUProcess Background Assertion' for process with PID=66540, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}
Deployment target is 10.15, Xcode version is 15.3.
Post not yet marked as solved
Hi,
We have recently observed that support for PWAs has been ended in the EU region in iOS 17.4. The changes were visible while the OS was in beta as well.
We have a web app with our user base in the US. Is there any plan for these restrictions to be implemented in any other region?
Post not yet marked as solved
I'm currently using a WKWebView to load certain types of documents via loadRequest, but I've recently been running into an issue with .doc files doing this:
static NSString *customScheme = @"customscheme";
@interface WordDocWKSchemeHandler : NSObject <WKURLSchemeHandler>
@end
@implementation WordDocWKSchemeHandler {
NSData *_data;
NSString *_mimeType;
}
- (instancetype)initWithData:(NSData*)data mimeType:(NSString*)mimeType{
self = [super init];
if (self) {
_data = data;
_mimeType = mimeType;
}
return self;
}
- (void)webView:(WKWebView *)webView startURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask {
NSURL *url = urlSchemeTask.request.URL;
if (![url.scheme isEqualToString:customScheme]){
return;
}
NSURLResponse *response = [[NSURLResponse alloc] initWithURL:url MIMEType:_mimeType expectedContentLength:_data.length textEncodingName:@""];
[urlSchemeTask didReceiveResponse:response];
[urlSchemeTask didReceiveData:_data];
[urlSchemeTask didFinish];
}
- (void)webView:(WKWebView *)webView stopURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask{
//empty
}
@end
- (void)_setupWebViewPropertiesAndConstraints{
_webView.navigationDelegate = self;
_webView.hidden = YES;
[self.view addConstrainedSubview:_webView];
[self.view addConstraints:[_webView constraintsForFillingSuperview]];
self.container.showsLoadingIndicator = YES;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
WKWebViewConfiguration *docConfig = [WKWebViewConfiguration new];
WordDocWKSchemeHandler *schemeHanlder = [[WordDocWKSchemeHandler alloc] initWithData:_content.data mimeType:_content.contentType];
[docConfig setURLSchemeHandler:schemeHanlder forURLScheme:customScheme];
//Setup webview with custom config handler
_webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:docConfig];
[self _setupWebViewPropertiesAndConstraints];
NSURL *customURL = [NSURL URLWithString:[NSString stringWithFormat:@"\%@:/",customScheme]];
[_webView loadRequest:[NSURLRequest requestWithURL:customURL]];
}
The mimeType is correctly being resolved to "application/msword" but any time we try to load this the navigation fails:
-(void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error {
The error message here is OfficeImportErrorDomain Code=912.
I've tried this on both a simulator and actual device on iOS 17 and 16 and this always fails. I've also tried turning the data into a base64 string and loading it that way and this also fails.
Any advice here would be appreciated. It seems like this used to work at some point but no longer works.
Post not yet marked as solved
Hi Apple Team, we are observing following error intermittently when trying to playback FairPlay protected HLS streams. The error happens immediately after loading the certificate.
Playback with same certificate on same device(Mac, iPhone) works most of time but intermittently this error is observed with following codes. The code=6 means MEDIA_KEYERR_DOMAIN but I did not find any information on what does systemCode=4294955417 mean? Is there a way to check what does this system code mean and what could be causing this intermittent behaviour?
{
"code": 6,
"systemCode": 4294955417
}
Post not yet marked as solved
Xcode 15.3 build with device(iPhone 12 / iOS 17.4)
var webView: WKWebView = {
let view = WKWebView(frame: .zero, configuration: WKWebViewConfiguration())
return view
}()
Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1a049fa48)
Hello.
Also in Firebase too. At first I thought it was a Firebase issue.
https://github.com/firebase/firebase-ios-sdk/issues/12485
But there seems to be a problem with iOS 17.4.
There is no problem when running the app after disconnecting.
Thanks for attention.
Post not yet marked as solved
We have an angular/ionic based app that has an audio playback feature. It appears that iphone (but not ipad) users who upgrade to iOS 17.4 can no longer play audio in our app. iPad users who upgraded to 17.4 don't have an issue.
We use the HTMLAudioElement for audio playback. It appears that in 17.4 it is no longer firing the 'canplay' event that we listening for, for starting our playback. The other data buffering events like 'loadeddata' are also not being delivered. By changing the logic to listen for the 'loadstart' event, audio playback works and then the remaining 'canplaythrough' and 'canplay' are delivered. In other words, I need to start playback before any data buffering status events are delivered, otherwise they never get delivered. I am testing this against an audio delivery server on my same machine and have confirmed that the data is correctly delivered.
Is anyone else experiencing a similar issue on iphones in iOS 17.4?
Good morning!
I am developing an iOS app that gets its data from an API and displays it in a list. The list item view has NavigationLink embedded in it that sends users to a detail view. In this detail view, I have some Text views but the issue I am running into is a WKWebView that I have implemented to display some HTML that's is retrieved from the API call.
The WKWebView displays the HTML just how I want it to. The issue I have is in the HyperLinks that are displayed in the WKWebView. When a user taps on a link, it opens inside of the web view. Instead of opening in the web view, I would like this link to open in the user's default web browser. I have searched and found ways of doing this in older versions of Swift using classes but my web view is initialized inside of a struct that conforms to the UIViewRepresentable protocol.
I don't know how to get links to open in the browser instead of the WebView so any help would be appreciated. Here is the code for my WebView that is being used on the details page.
struct NewsItemWebView: UIViewRepresentable {
// HTML from API Call
var text: String
// Method to create the View
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
// Method to update the View by changing properties of the WebView
func updateUIView(_ uiView: WKWebView, context: Context) {
uiView.isOpaque = false
uiView.backgroundColor = UIColor.white
uiView.loadHTMLString(text, baseURL: nil)
}
}
Here is how I am implementing the WebView on DetailView
NewsItemWebView(text: item.PageContent)
.frame(height: 450)
Any help on how I can make links open in a browser would be great. Thanks in advance.
Post not yet marked as solved
Hi folks, I have a couple questions relating to the user gesture requirement on iOS, specifically regarding WebKit.
From my testing, it looks like only one webauthn invocation without user gesture is allowed even if there's intervening user gestures, e.g. navigating to another page, clicking buttons, etc. I have to close Safari and reopen in order to reset the count. Is this expected behavior? It seems like it was originally supposed to be one per user navigation [1].
I see the user gesture requirement was removed recently [2]. I agree with the decision, but am curious what was the context behind this move as it seems like a reversal of https://webkit.org/blog/11312/meet-face-id-and-touch-id-for-the-web/.
[1] https://bugs.webkit.org/show_bug.cgi?id=220897
[2] https://bugs.webkit.org/show_bug.cgi?id=264444
I am having a problem when trying to implement a WKWebView in a window in VisionOS and that when trying to do it in full screen and exiting full screen, the size of the webview changes, becoming smaller or larger while the window remains the same size as before.
I used webView.configuration.preferences.isElementFullscreenEnabled = true for enabling fullscreen mode. I made a simple code to test this.
import SwiftUI
@main
struct TestApp: App {
var body: some Scene {
WindowGroup() {
ContentView()
}
}
}
import SwiftUI
import WebKit
struct WebView: UIViewRepresentable {
let url: URL
func makeUIView(context: Context) -> WKWebView {
let wkwebView = WKWebView()
wkwebView.configuration.preferences.isElementFullscreenEnabled = true
let request = URLRequest(url: url)
wkwebView.load(request)
return wkwebView
}
func updateUIView(_ uiView: WKWebView, context: Context) {
}
}
struct ContentView: View {
var body: some View {
WebView(url: URL(string: "https://glitch.com/~fullscreen-test")!)
}
}
Post not yet marked as solved
Problem statement-
WKWebView cookies management. We need to clone the connection used by the WKWebView to the same end point, this connection utilize cookies for routing and missing even one the cookies will end up with a wrong route to be used. It appears that when retrieving the cookies from the WKWebView connection some cookies are missing. From some analysis seems that the missing cookies all have in common a value containing special characters. The question for Apple is if they are going to relax the constraint on cookies value to allow such cookies to be used.
Technical Description:-
We are using WKWebView. There are some cookies being set during server connection. We are retrieving all cookies using 'getAllCookies' method of WKWebview. Sometime its not giving correct set of cookies in case if there are any special characters in any cookie.
For example -
Cookie- ss2QKagAdkAV3My1pnKElaFDnQ6lxhgqNbD03IaRbX6WfDz2+P9dT6DdlK8G5WIH3svEATnehZSmWGQ3QFTnew==\n
It contains special character "+ = !".
Post not yet marked as solved
In iMessage you can link a twitter post and it gets the image (if any), tweet content and title. Yet as a regular dev, I think, that we cannot get the tweet content like iMessage.
From this Github issue of Mastodon, I know that in the header there is everything we need, yet in a simple swift code using LPLinkMetadata we cannot get the description. Here is the code below
import SwiftUI
import LinkPresentation
class LinkViewModel : ObservableObject {
let metadataProvider = LPMetadataProvider()
@Published var metadata: LPLinkMetadata?
@Published var image: UIImage?
init(link : String) {
guard let url = URL(string: link) else {
return
}
metadataProvider.startFetchingMetadata(for: url) { (metadata, error) in
guard error == nil else {
assertionFailure("Error")
return
}
DispatchQueue.main.async {
self.metadata = metadata
}
guard let imageProvider = metadata?.imageProvider else { return }
imageProvider.loadObject(ofClass: UIImage.self) { (image, error) in
guard error == nil else {
// handle error
return
}
if let image = image as? UIImage {
// do something with image
DispatchQueue.main.async {
self.image = image
}
} else {
print("no image available")
}
}
}
}
}
struct MetadataView : View {
@StateObject var vm : LinkViewModel
var body: some View {
VStack {
if let metadata = vm.metadata {
Text(metadata.title ?? "no title")
Text(metadata.value(forKey: "_summary") as? String ?? "np description" )
}
if let uiImage = vm.image {
Image(uiImage: uiImage)
.resizable()
.frame(width: 100, height: 100)
}
}
}
}
struct ContentView: View {
var links = [ "https://www.google.com", "https://www.hotmail.com", "https://twitter.com/t3dotgg/status/1764398959513276630"]
let metadataProvider = LPMetadataProvider()
var body: some View {
List(links, id:\.self) { item in
Section{
VStack {
Text(item)
MetadataView(vm: LinkViewModel(link: item))
}
}
}
}
}
The twitter link doesn't return any description, I also tried third party OG libraries with the og:title in Swift with no success, yet it works on iMessage.
Any tips ? :-)
Post not yet marked as solved
Getting the document data from a server using JSON encoded to Base64.
WKWebView is not rendering .docx file accurately. The docx file has logos in header and watermark at the background which is not displayed correctly to the user.
Steps taken to load the docx file in WKWebview:
Stored the document data on app documents directory.
Displaying the document file in WKWebView on mobile app with help of local document directory file path.
Below is the code that renders the docx file:
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
let filePath = String(format: "%@/%@", documentsPath, "file.docx")
let fileURL = URL(fileURLWithPath: filePath)
docWebView.loadFileURL(fileURL, allowingReadAccessTo: fileURL)
Has anyone encountered this issue? Please provide some assistance to resolve this issue.
Post not yet marked as solved
The iOS 17.4 beta4 version was released this Tue(Feb.20). we received lots of web view crashes in this version. we have checkout our udpates we didn't do related code changes recently.
Do you meet similar issues in your app? anyone can give some advices?
Thanks
By crash report in Xcode, the crash frame is
WebKit: ***::Detail::CallableWrapper<WebKit::ProcessLauncher::launchProcess()::$_0::operator()(***::ThreadSafeWeakPtr<WebKit::ProcessLauncher>, _SEExtensionProcess*, ***::ASCIILiteral, NSError*) const::'la... + 2480
screenshot for the call stack is