Display web content in windows and implement browser features using WebKit.

WebKit Documentation

Posts under WebKit tag

275 Posts
Sort by:
Post not yet marked as solved
2 Replies
48 Views
Hi, I'm trying to implement a type conforming to WKScriptMessageHandlerWithReply while having Swift's strict concurrency checking enabled. It's not been fun. The protocol contains the following method (there's also one with a callback, but we're in 2024): func userContentController( controller: WKUserContentController, didReceive message: WKScriptMessage ) async -> (Any?, String?) WKScriptMessage's properties like body must be accessed on the main thread. But since WKScriptMessageHandlerWithReply is not @MainActor, neither can this method be so marked (same for the conforming type). At the same time WKScriptMessage is not Sendable, so I can't handle it in Task { @MainActor in this method, because that leads to Capture of 'message' with non-sendable type 'WKScriptMessage' in a `@Sendable` closure That leaves me with @preconcurrency import - is that the way to go? Should I file a feedback for this or is it somehow working as intended?
Posted
by
Post not yet marked as solved
0 Replies
38 Views
Hi Apple Team, We have a PWA which supports downloading and playback for audio and video content. Downloaded content is stored in IndexedDB in the form of blobs and blob URLs are generated on runtime through which content is played. We have observed that the blob URLs have stopped working on iOS 17.4.1. They work on iOS 17.4 and iOS 17.3 as well. This feature is very critical for us as it is the heart of the offline mode of the app. Thanks!
Posted
by
Post not yet marked as solved
1 Replies
91 Views
As part of a university project, we need to be able to display a website on an Apple Watch and log in to a service. Is it possible to get access to the WebKit framework in a watchOS app? We also need to be able to execute JavaScripts in the browser so that the login process works.
Posted
by
Post not yet marked as solved
0 Replies
111 Views
Hi. I plan to use a WebView in an iOS app (SWIFT) and this should run a web app with WASM and using IndexedDB for permanent credentials. I found rumors and information on Apple deleting data in IndexedDB and localStorage after 7 days (see links below). But I found no official information that tells me if this is true for my WebView in my ordinary mobile App (not PWA). A test cycle over a week to find out is hard to do... Is there any reliable and clear information on this and am I affected? Thank you! . Links about this topic: https://news.ycombinator.com/item?id=28158407 https://www.reddit.com/r/javascript/comments/foqxp9/webkit_will_delete_all_local_storage_including/ https://searchengineland.com/what-safaris-7-day-cap-on-script-writeable-storage-means-for-pwa-developers-332519
Posted
by
Post not yet marked as solved
0 Replies
116 Views
I have an HTTP3 relay setup and I'm trying to get WKWebView traffic to use it. The relay has a self-signed certificate for TLS traffic. When using URLSession to make a call, everything works as expected, but in WKWebView, it doesn't. Here is how I setup my ProxyConfiguration let options = NWProtocolTLS.Options() // sample options to trust any certificate for testing sec_protocol_options_set_verify_block(options.securityProtocolOptions, { (sec_protocol_metadata, sec_trust, sec_protocol_verify_complete) in sec_protocol_verify_complete(true) }, DispatchQueue.global()) let relayServer = ProxyConfiguration.RelayHop(http3RelayEndpoint: relayEndpoint, tlsOptions: options) let relayConfig = ProxyConfiguration(relayHops: [relayServer]) I connect that to my webview by simply doing the following: let configuration = WKWebViewConfiguration() configuration.websiteDataStore = WKWebsiteDataStore.nonPersistent() configuration.websiteDataStore.proxyConfigurations = [relayConfig] let webView = WKWebView(frame: .zero, configuration: configuration) The sec_protocol_options_set_verify_block is never called for the WKWebView (it is when I use URLSession) I get the following error in XCode [pageProxyID=7, webPageID=8, PID=73105] WebPageProxy::didFailProvisionalLoadForFrame: frameID=1, isMainFrame=1, domain=NSURLErrorDomain, code=-1202, isMainFrame=1, willInternallyHandleFailure=0 Is there some API I am missing to get the webview to do custom TLS validation with an HTTP3 relay?
Posted
by
Post not yet marked as solved
0 Replies
227 Views
Hello We received frequent crashes for the webkit on 17.4.1. We checked the code as well nothing got changed from our side. I tried to reproduce it but unable to do so. Can anybody advice on this. Below is the stack trace for same Please help to check. Thanks in advance
Posted
by
Post not yet marked as solved
0 Replies
143 Views
I would like to specify "Connection: close" for a request that I load in WKWebView - which actually CAN be done by setting the value on the request that is loaded (and it actually works). However, the documentation at https://developer.apple.com/documentation/foundation/nsurlrequest#1776617 states that it shouldn't be used because the URL loading system handles persistent connections for you. So - my question is how can I indicate to the URL Loading System that I do NOT want to use persistent connections for this particular request? Or - am I safe to just set the header even though it's listed as reserved (because - as mentioned - it does work)?
Posted
by
Post not yet marked as solved
0 Replies
171 Views
On ios15, when loading a page, occasionally all resources under a domain name cannot be loaded. the code like this: <html><head> <title>issue page</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> </style></head> <body><div> <script type="text/javascript" src="https://wx.qq.com/open/js/jweixin-1.6.0.js"></script> <script type="text/javascript" src="https://wap.xxxx.com/static/webapp/common_res/3rd/jquery-3.6.2.min.js"></script> <script type="text/javascript" src="https://statres.ok.com/quickapp/js/qa_router.min.js"></script> <script type="text/javascript" src="https://wap.xxxx.com/static/webapp/common_res/js/utils.min.js"></script> </div></html> This is a simplified page code. The problem is that the page cannot be loaded. Resources under wx.qq.com and statres.ok.com can be loaded, but all resources under wap.xxxx.com fail to be loaded. (Debugging via safari) wkwebview did not call back to didFinishNavigation, and the page load progress was stuck at 0.5. And then it didn't go out of time. It just stayed there. Here are some of the solutions I tried: 1、At first I thought it was a resource problem, but everything worked fine when I copied it to safari. In addition, most of the time in my page is fine, but once this problem occurs, the page will no longer load out until I restart the app. 2、thought is to cache problem, repetition, I added NSURLRequestReloadIgnoringLocalCacheData, also was not used. 3、 I captured the system logs through idevicesyslog and found no obvious anomalies in webkit. 4、When I used wireshark to find the problem, wap.xxxx.com did not even initiate dns requests, as if the browser ignored the resource.(Normally, I caught the dns request for this page) Please help me divergent ideas, thank you!
Posted
by
Post not yet marked as solved
0 Replies
179 Views
I am currently developing an iOS app that needs to embed a third-party website. On this website, the best view is achieved in the standard Safari app by pressing the 'Aa' button on the left side of the address bar and setting the zoom to 50%. I want to replicate this 50% scaling in WKWebView, but I'm not sure how to accomplish it. I've tried using webView.pageZoom = 0.5 and setting webView.scrollView.minimumZoomScale = 0.5 webView.scrollView.maximumZoomScale = 0.5 but it doesn't display the same way as it does in Safari. How can I achieve the same scaling effect in WKWebView?
Posted
by
Post not yet marked as solved
11 Replies
374 Views
In iOS version 17.4 and above, we have observed that the following code works fine upon the initial opening. However, after minimizing the page and reopening it, there is a chance of encountering issues with abnormal lines. Please note the reproduction conditions: try minimizing the page, opening other apps, and then reopening it multiple times. The code is in the comments section. first time: After minimizing and reopening...
Posted
by
Post not yet marked as solved
3 Replies
323 Views
in demo ,load index.html into WKWebView, when i click file button, the camera page present and then dismiss quickly ViewController.h @property (nonatomic, strong) WKWebView *wkWebView; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; WKWebViewConfiguration *configuration = [WKWebViewConfiguration new]; self.wkWebView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 400, 300) configuration:configuration]; NSURL *url = [[NSBundle mainBundle] URLForResource:@"index" withExtension:@"html"]; [self.wkWebView loadFileURL:url allowingReadAccessToURL:[[NSBundle mainBundle] bundleURL]]; self.wkWebView.backgroundColor = [UIColor blueColor]; [self.view addSubview:self.wkWebView]; } index. html <html lang="en"> <head> <meta charset="UTF-8"> </head> <body> <div> <label style="font-size: 40px;">open camera</label> <input type="file" accept="image/*" capture="camera" id="file-input" class="file-input"> </div> </body> </html>
Posted
by
Post not yet marked as solved
0 Replies
154 Views
I am trying to sync up the selected tab bar item once a user presses back and navigates back in the web wrapper iOS app. Here is how the app works: When a user logs in, they are presented with the Home Screen. To navigate, the select a tab item on the tab bar. This tells webkit to redirect to that URL and then that webpage is shown in the app (wrapped). A back button also appears. When a user presses the back button, the webView.goBack() method sends the user back on in the webView.backForwardList. What happens then is that the user is now on the previous page, however the tab bar has not updated. In other words, the user is back on the first tab but the second tab is highlighted. I tried fixing this by telling the tab bar controller what item to select, however this creates a state malfunction because it also tells the webView to navigate to that url again, so in fact this means that the user isn't going back through web history, but actually is going forward while simulating going back. I need to be able to highlight the tab bar items that sync up with the page that we have gone back to without selecting it. Does anyone have an idea for how to manually highlight or select a tab bar item without actually navigating to that tab bar item? Thank you!
Posted
by
Post not yet marked as solved
3 Replies
319 Views
appState=foreground 2024-04-10 10:01:12:439,IPHONE_1ND,10.5.80.6000,3,460000000000000|86dmsu7m2t8cs7w,83D44481-559B-4D5D-BC1F-2E643CF08A16,2088512449022223,exception,-,call_write_crash_log_api,-,-,MonitorPoint_Crash,-,apple-iphone,release,-,-,-,-,-,iPhone16 2,17.4.1,WIFI|--,-,10.5.80.6000,ZbsnB/YU+YsDAEHUUPE53+9a,follow_system_zh-Hans-CN,-,-,-,-,-,-,VoiceOver=0^TimeZone=Asia/Shanghai^AppStatus=background^CIP=(null)^AppSession=195C885D-0152-46E8-8E6D-F6D38D5E0A81^appMode=normal^editionId=300003^lowEnd=T^buildNumber=21E236^simC=2,1,00000000-0000-0000-0000-000000000000 Incident Identifier: 795088EB-76F2-460F-A323-9290DEE9B37F CrashReporter Key: Hardware Model: iPhone16 2 Process: AlipayWallet [972] Path: /private/var/containers/Bundle/Application/EAD57E87-932E-4952-9714-C0B852F3A773/AlipayWallet.app/AlipayWallet Identifier: com.alipay.iphoneclient Version: 10.5.80 (10.5.80.6000) Code Type: ARM-64 Parent Process: [1] Date/Time: 2024-04-10 02:00:47 +0000 OS Version: iPhone OS 17.4.1 (21E236) Report Version: 104 Exception Type: SIGBUS Exception Codes: BUS_ADRERR at 0x16b477fe8 Crashed Thread: 0 Thread 0 Crashed: 0 CoreFoundation 0x0000000190fd5aa8 _generationCountFromListOfSources :104 (in CoreFoundation) 1 CoreFoundation 0x0000000190fd389c -[CFPrefsSearchListSource alreadylocked_generationCountFromListOfSources:count:] :80 (in CoreFoundation) 2 CoreFoundation 0x0000000190f7a3fc -[CFPrefsSearchListSource alreadylocked_getDictionary:] :492 (in CoreFoundation) 3 CoreFoundation 0x0000000190f79f68 -[CFPrefsSearchListSource alreadylocked_copyValueForKey:] :172 (in CoreFoundation) 4 CoreFoundation 0x0000000190f79e9c -[CFPrefsSource copyValueForKey:] :52 (in CoreFoundation) 5 CoreFoundation 0x0000000190f79e50 ___76-[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:]_block_invoke :32 (in CoreFoundation) 6 CoreFoundation 0x0000000190fcafb4 ___108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke :392 (in CoreFoundation) 7 CoreFoundation 0x0000000190fcadc4 _normalizeQuintuplet :356 (in CoreFoundation) 8 CoreFoundation 0x0000000190fcac38 -[_CFXPreferences withSearchListForIdentifier:container:cloudConfigurationURL:perform:] :164 (in CoreFoundation) 9 CoreFoundation 0x0000000190fcab38 -[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:] :156 (in CoreFoundation) 10 CoreFoundation 0x0000000190fca940 __CFPreferencesCopyAppValueWithContainerAndConfiguration :112 (in CoreFoundation) 11 CoreFoundation 0x000000019101a5ec __CFPreferencesGetAppIntegerValueWithContainer :56 (in CoreFoundation) 12 WebKit 0x00000001a651d77c -[WKWebViewConfiguration init] :232 (in WebKit) 13 WebKit 0x00000001a651de28 -[WKWebViewConfiguration copyWithZone:] :48 (in WebKit) 14 WebKit 0x00000001a64e00f8 -[WKWebView configuration] :28 (in WebKit) 15 WebKit 0x00000001a6d93d54 -[WKContentView(WKInteraction) _cascadeInteractionTintColor] :36 (in WebKit) 16 WebKit 0x00000001a6d93f3c -[WKContentView(WKInteraction) _updateTextInputTraitsForInteractionTintColor] :24 (in WebKit) 17 WebKit 0x00000001a6d9d0d0 -[WKContentView(WKInteraction) _updateTextInputTraits:] :1004 (in WebKit) 18 WebKit 0x00000001a6db5de0 -[WKContentView(WKInteraction) extendedTraitsDelegate] :136 (in WebKit) 19 WebKit 0x00000001a6d93a54 -[WKContentView(WKInteraction) insertionPointColor] :48 (in WebKit) 20 UIKitCore 0x000000019338f674 +[UIKBRenderConfig configForAppearance:inputMode:traitEnvironment:] :272 (in UIKitCore) 21 UIKitCore 0x000000019338eb9c -[UIView(UIKB_UIViewExtras) _inheritedRenderConfig] :332 (in UIKitCore) 22 UIKitCore 0x0000000193d32794 -[UICandidateViewController overrideUserInterfaceStyle] :44 (in UIKitCore) 23 UIKitCore 0x00000001939790c4 ___78-[UIViewController _traitCollectionByApplyingLocalOverridesToTraitCollection:]_block_invoke :172 (in UIKitCore) 24 UIKitCore 0x00000001931fbd10 -[UITraitCollection _traitCollectionByModifyingTraitsCopyOnWrite:] :252 (in UIKitCore) 25 UIKitCore 0x0000000193978b08 -[UIViewController _traitCollectionByApplyingLocalOverridesToTraitCollection:] :116 (in UIKitCore) 26 UIKitCore 0x0000000193201c40 -[UIViewController traitCollection] :228 (in UIKitCore) 27 UIKitCore 0x0000000193206a9c __UIGetCurrentFallbackTraitCollection :180 (in UIKitCore) 28 UIKitCore 0x0000000193205568 _UIViewCommonInitWithFrame :548 (in UIKitCore) 29 UIKitCore 0x00000001932052f4 -[UIView initWithFrame:] :132 (in UIKitCore)
Posted
by
Post not yet marked as solved
2 Replies
253 Views
Hi Everyone, I scanned my iPhone SE 3d generation with the iMazing app developed by Amnesty International, and after the scan it detected 3 Warnings on my iphone. Any of you is able to understand what´s the issue is about? That would be great help! Following the 3 Warnings: Warning - Database Query Error - WebKit Observations - 'AppDomain-com.apple.tips/Library/WebKit/WebsiteData/ResourceLoadStatistics/observations.db' cannot be parsed (no such table: ObservedDomains). Warning - Database Query Error - InteractionC - 'HomeDomain/Library/CoreDuet/People/interactionC.db' cannot be parsed (no such table: ZINTERACTIONS). Warning - Database Query Error - InteractionC Attachment - 'HomeDomain/Library/CoreDuet/People/interactionC.db' cannot be parsed (no such table: ZATTACHMENT).
Posted
by
Post not yet marked as solved
1 Replies
188 Views
I modified an InputMethodKit example (fairly recent one from github, compiled fine and worked as expected on my machine as it was) to create a window with a WKWebView and the window doesn't load. I know that loadView is getting called, but the window never appears after calling showWindow on the window controller and there is a mysterious error in the console: bootstrap_check_in(): (os/kern) unknown error code (44c) From googling this it seems App Sandbox related, but I think I have everything set up correctly (App Sandbox on with outgoing connections allowed) Totally stumped, any help or ideas would be appreciated Here's the relevant code: View controller import Foundation import WebKit import AppKit class InputWindowViewController: NSViewController, WKUIDelegate { var webView: WKWebView! override func loadView() { NSLog("LoadView") webView = WKWebView() self.view = webView webView.uiDelegate = self webView.needsDisplay = true } override func viewDidLoad() { super.viewDidLoad() webView.load(URLRequest(url: URL(string:"https://www.apple.com")!)) } } Window controller import AppKit import Foundation import WebKit class InputWindowController: NSWindowController { var controller: InputWindowViewController? override init(window: NSWindow?) { controller = nil super.init(window: window) } override func loadWindow() { self.window = NSWindow(contentViewController: controller!) } required init?(coder: NSCoder) { controller = nil super.init(coder: coder) } } AppDelegate import Cocoa import InputMethodKit import WebKit // Necessary to launch this app class NSManualApplication: NSApplication { private let appDelegate = AppDelegate() override init() { super.init() self.delegate = appDelegate } required init?(coder: NSCoder) { // No need for implementation fatalError("init(coder:) has not been implemented") } } @main class AppDelegate: NSResponder, NSApplicationDelegate { var server = IMKServer() var candidates = IMKCandidates() var inputWindowController = InputWindowController() func applicationDidFinishLaunching(_ notification: Notification) { // Insert code here to initialize your application server = IMKServer(name: Bundle.main.infoDictionary?["InputMethodConnectionName"] as? String, bundleIdentifier: Bundle.main.bundleIdentifier) inputWindowController = InputWindowController() inputWindowController.controller = InputWindowViewController() inputWindowController.loadWindow() inputWindowController.showWindow(self) candidates = IMKCandidates(server: server, panelType: kIMKSingleRowSteppingCandidatePanel, styleType: kIMKMain) NSLog("tried connection") } func applicationWillTerminate(_ notification: Notification) { // Insert code here to tear down your application } } This code is probably awful in a lot of other ways I don't realize, but I wanted to get a webview window up before I put a bunch of time into this thing XCode 13.4 MacoOS 12.7.4
Posted
by
Post not yet marked as solved
0 Replies
208 Views
I am currently working on an iOS application where I want to implement the safari tabs and when I have to minimize that one to check how many numbers of tabs are opened. How can I do this?
Posted
by
Post not yet marked as solved
4 Replies
812 Views
Hi all, An app that until yesterday would take 1 second to render a list in the WKWebView is now taking over 3 minutes to load. No changes have been made to the app or the content that it is showing. I have tested on a device running 17.3, and performance has been acceptable, and then updated to the latest security fix (17.4.1) and now 3 minutes. Having read the release notes https://support.apple.com/en-us/HT214097 I cant see what would have affected either the processing of javascript or the rendering of content within the web view. My team is currently running all our apps that use a hosted WKWebView within it to ensure that they aren't affected, but this one app is now unusable and safety concern for the users (Airline Safety). Has anyone else experienced this or has a workaround - Sorry there are no logs (I have been scanning the device logs and nothing new is appearing - almost as if the operation is just dead locked).
Posted
by
Post not yet marked as solved
0 Replies
240 Views
Hello, Currently, my app only uses web view to load HTML data and external safari web view by link click. I have seen the following developer's details. So if HTML data load on web view needs data collection enabled, then which Types of data need to be added to data collection? Also. if we disable all types of Data collection from privacy. Is apple will allow you to submit the app? or Reject it? Any help will be appreciated. Thanks
Posted
by
Post not yet marked as solved
0 Replies
310 Views
Hello Apple We have read your guide on https://developer.apple.com/documentation/bundleresources/privacy_manifest_files#4284009 and it is unclear how the NSPrivacyTrackingDomains affects WebView functionality of the app. We have WebView based functionality we use for signup/ login of customers in the app and that can potentially track users. It is stated that If the user has not granted tracking permission through the App Tracking Transparency framework, network requests to these domains fail and your app receives an error. However based on our testing the domains listed in NSPrivacyTrackingDomains have no effect on network requests happening in the WebView if the user declines tracking via the App Tracking Transparency prompt. (e.g pages are loaded, network requests to listed tracking domains are happening) Can you confirm it is the case on what should de done about it? Right now we have a custom implementation on our side that passes the result of the App Tracking Transparency prompt to the WebView instructing it weather it can send requests to tracking domains or not.
Posted
by