Explore the integration of web technologies within your app. Discuss building web-based apps, leveraging Safari functionalities, and integrating with web services.

General Documentation

Post

Replies

Boosts

Views

Activity

How to make a simple back button.
So I am trying to control the wkwebview content within my app. When I try the following code> var backButton: some View { Button(action: { webView.goBack() // Add your back button action here }, label: { Image(systemName: "arrow.uturn.backward") .font(.title) }) .navigationBarBackButtonHidden(true) } I get webView out of scope. This is how I have webView implimented struct WebView: UIViewRepresentable { let url: URL let preferences = WKPreferences() let useragent = WKWebViewConfiguration() func makeUIView(context: Context) -> WKWebView { @State var webView = WKWebView() let request = URLRequest(url: url) useragent.applicationNameForUserAgent = "Version/1.2 LavaRock/1.2" useragent.allowsAirPlayForMediaPlayback = true useragent.allowsInlineMediaPlayback = true useragent.allowsPictureInPictureMediaPlayback = true // preferences.isFraudulentWebsiteWarningEnabled = true preferences.isSiteSpecificQuirksModeEnabled = true preferences.isElementFullscreenEnabled = true webView.allowsBackForwardNavigationGestures = true // webView.configuration.allowsPictureInPictureMediaPlayback = true webView.customUserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Version/1.2 LavaRock/1.2" webView.load(request) return webView } func updateUIView(_ uiView: WKWebView, context: Context) { // Handle view updates if needed } } How should create the button?
0
0
142
1w
An error occurred try to load the resource: The issue only occurs when the download modal display and the image fetching for the pop-up are conducted simultaneously.
Problem Details : In the case of iOS, the image to be displayed in the pop-up message within the TypeScript application does not appear during file download. An error occurred trying to load the resource when attempting to fetch the image (in the case of Safari). The image does not appear in Edge or Chrome either, besides Safari. The image is displayed correctly on Windows 10, 11, Mac Ventura, Mac Sonoma, and Android. Neither svg format nor png format images are displayed. Only in the case of iOS, a download modal appears in Safari (In Edge and Chrome, a different display asking whether or not to download appears, which is different from the modal). The issue only occurs when the download modal display and the image fetching for the pop-up are conducted simultaneously. If you delay the display of the download modal from the timing of fetching the image for the pop-up (apply a wait), the image can be fetched. Verification Environment: iOS v.17.5.1 Safari 604.1 iOS v.17.3 Safari 604.1 IOS v.17.4.1 Chrome 126.0.6478.54 IOS v.17.4.1 Edge: 125.0.2535.72 Consideration and Request: Based on the problem details, I am considering that this issue might be a bug in iOS. I would like to know from experts whether this event is a bug or a specification of iOS. If there is any information about similar events occurring, I would like to know. If there are any solutions, hints, or advice, I would appreciate it if you could provide them. If additional information is required from me, I would like to be contacted. Thank you for your cooperation.
0
0
152
1w
Why is the Safari extension installed on my iPhone unstable?
We are developing an application using Safari extensions (iOS 16, 17). When the Safari extension is enabled, it does not function properly in Safari. On an iPhone, the issue can be temporarily resolved by repeating the following steps: 1.Go to "Settings" → "Safari" → "Extensions" and toggle the extension off and on. 2.Go to "Settings" → "Safari" → "Clear History and Website Data." 3.Restart the iPhone. However, these methods do not consistently resolve the issue, and a definitive solution has not been identified. Does the Safari extension's JavaScript have a caching mechanism? If it does, what are the recommended methods to address this issue?
0
0
144
1w
Pre-rendering WKWebView to avoid flashing
Has anyone attempted to render a WKWebView in a background or invisible UIView so that it’s visible immediately upon first presentation, and if so, what technique did you use? Background: We are trying to embed a WKWebView in our UI that renders seamlessly next to native UI. We are going to download a .ZIP file, unzip it locally to disk, and then point the WKWebView to that local file. However, when testing this solution on an iOS simulator (running iOS 17.5), we see a flash of white – specifically there is no content rendered for the first moment or two, followed by content appearing. We have tried attaching the WKWebView to the UIWindow, adding a javascript callback for the onReadyStateChange “loaded” event, and then only proceeding to present our UIViewController containing our WKWebView afterwards, but we still see a moment with no content being rendered at all. If we add a delay using DispatchQueue.asyncAfter of approximately one second (anything less still flashes), our content does seem to be correctly rendered in the background and immediately visible when the UIViewController gets presented. This is a problem that was originally asked nearly 11 years ago (https://stackoverflow.com/questions/15669809/how-to-prevent-initial-white-flash-when-showing-a-uiwebview); and the agreed upon solution there seems to be to set the background to be not opaque, but the issue remains that the content isn’t immediately visible. Google Gemini and ChatGPT have proposed a number of solutions, including hallucinations about headless WKWebView support on iOS, but unfortunately we are unable to achieve a solution without a DispatchQueue delay with a magic number.
0
0
143
1w
iOS 16, iOS 17, MacOS Sonoma, Safari 17.5, permissionStatus.onchange not working
navigator.permissions.query -> permissionStatus.onchange is Supposed to listen to the event of a change in permissions in the browser settings. This works for all browsers, but in Safari for iOS and MacOS this seems to be broken in the currently recent versions 17.x Example: navigator.permissions.query({ name: 'notifications' }).then((permissionStatus) => { permissions = permissionStatus.state; // this value gets set correctly permissionStatus.onchange = () => { // This will not get executed when permissions have been changed // within the safari settings app, or iOS Settings for PWA or Safari }; }); Can someone from Apple's Webkit Team please comment on this? Thank you. T.
1
1
209
1w
Safari Extension browser.tabs.query returns invalid results
When you have a blank Safari new tab open, the browser.tabs.query API inaccurately includes those tabs in results that include a url or title in the query options. To reproduce, open several tabs, and a blank new tab. Open the background page devtools, and execute the following command: browser.tabs.query({url: 'https://github.com/'}, console.log) In addition to any potentially valid results (if you have github.com open, for example), there will also be an entry for the blank tab, which has an empty, non-matching URL. Tab { active: true, audible: false, height: 1095, highlighted: true, id: 6, incognito: false, index: 3, isArticle: false, isInReaderMode: false, mutedInfo: {muted: false}, pendingUrl: "", pinned: false, status: "complete", title: "", url: "", width: 1792, windowId: 1 } I hope that this bug can be addressed, as it causes some unexpected behavior.
1
0
617
May ’23
Safari Web Extension runs fine on Simulator, but not on Device
I am writing this Web Extension for Safari. It is designed to run on both macOS and iOS. The extension-specific javascript/css/etc files are shared between the platforms. What I observe is that the extension is running fine on macOS. It also runs fine on the iOS Simulator. However, on my device, just nothing happens when activating the extension. No errors are output to the console either. I found it out the hard way, when I already released the extension in the AppStore, and installed it on a friend's iPhone. Does anyone have a clue where I even could start debugging? Or better: maybe there is just a simple checkbox that that I should (un)check?
0
0
159
1w
Camera accessing from sfsafariviewcontroller on IPhone 15 Pro
Hello, I am building a React webapp that will be opened in a webview (sfsafariviewcontroller) within an app. This simple app uses a camera to scan a barcode and get the hidden special price. During the QA test, we found that it does not work on iphone 15 pro while it works fine on other iphone series including iphone 8 plus, iphone 13, iphone 14, iphone 14 pro max. I updated IOS version to the latest on my iphone 14 pro max to match with the IOS version on iphone 15 pro, it still works fine on 14 pro max. So I think it could be an issue with the device version maybe with more privacy configuration or something else. In the app, there is another barcode scanner (using camera) and it works fine on the same device, but the scanner within the sfsafariviewcontroller shows a white blank screen. The red camera icon at the top is shown for a while and disappeared. Does anyone have the same issue? We specified the NSCameraUsageDescription in the info.plist. Any advice would be greatly appreciated!
0
0
192
2w
Import a debit/credit card directly from a web app into the iPhone's wallet
Hi, I know it's currently possible to import a virtual debit/credit card from a mobile app into the IOS Wallet using PassKit from the Apple SDK, but I haven't seen any documentation to do it directly from a web app, could you please tell me if it is possible to do it directly from a web app without using a mobile app? And if so, point me to some documentation? Thanks in advance
1
1
198
2w
JS error in WKWebView
I received this JS error: $(".tabs li").scaleText is not a function. on this web site (https://www.topmarks.co.uk/maths-games/hit-the-button --> click "Play Game") with the WKWebView in my app. The page works fine on Safari, chrome and even SFSafariViewController. Could anyone please help me on that? Thank you.
0
0
133
2w
Using SF Pro for a shop website.
Hello! I am looking to use SF Pro as the main font of my website. This website is used as a place of purchase for some of my products, none of which will actually be using this font. The websites logo will also not be using this font, however I am worried that may be legally unviable. Please let me know if this is an option. I'm not looking to get direct financial gain by using your fonts, just would like to use it for the website. Thank you for your help.
0
0
113
2w
Apache on macOS 15 Sequoia
I have found that using the both the built in Apache webserver and the Homebrew variant does not work with the ssl related modules enabled, I have not narrowed down which module specifically crashes httpd, but I believe I have narrowed it down to be one of the ones that are required to use ssl. It exits with zsh: abort sudo httpd -k start while printing dyld[31928]: Assertion failed: (this->magic == kMagic), function isDelayInit, file Loader.cpp, line 464. to the error_log. I can provide more details, right now I feel like I'm forgetting to add something but I can't think of what it is.
5
5
393
2w
Cookies set by AJAX responses not accessible by JS when using WKWebView
Hi, we have really weird issue with one of our website embedded into iOS app using WKWebView. The website has CSRF mechanism implemented and is using some AJAX calls when user interact with it and in response some cookies are returned. Then the JS code wants to access these cookies to set proper value for next request header. Unfortunately when using document.cookie JS command these cookies are not there. However they are sent within another requests and I can see them from Safari Developer Inspector connected to my device or iOS Simulator. Another interesting thing is that the same website and solution works fine on Safari browser and with SFSafariViewController displayed inside our app. We've tried using various things for WKWebView configuration like nonPersistent data store, but without success. Does anyone have any idea how to deal with such issue and why it doesn't work with WKWebView?
0
2
161
2w
Student in need of help
So the css in this post is broken only on iphones if we view it on an android phone then there is no issues, and I can't figure out why? the scroll background is looking wired, but it's defined by: width: 60px; height: 60px;... Anyhow i'm just wondering why the css is not working as it should? Please help me 🙏
0
0
127
2w
Crash WKWebView startURLSchemeTask
When I use - webView: startURLSchemeTask: , I had some crash with iOS 14(14.1, 14.2, 14.3, 14.4). There is the code: - (void)webView:(WKWebView *)webView startURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask API_AVAILABLE(ios(11.0)){ /// iOS 13可能有崩溃 NSString *version = [[UIDevice currentDevice] systemVersion]; if ([version containsString:@"13."]) { SEL sel = sel_registerName("_setLoadResourcesSerially:"); id webViewClass = NSClassFromString(@"WebView"); if ([webViewClass respondsToSelector:sel]) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-performSelector-leaks" [webViewClass performSelector:sel withObject:@(FALSE)]; #pragma clang diagnostic pop } }//fi self.holdUrlSchemeTasks[urlSchemeTask.description] = @(TRUE); SCNADHtmlPreloadContext *context = [[SCNADHtmlPreloadContext alloc] init]; context.requestURL = [urlSchemeTask.request.URL.absoluteString copy]; // line 50 context.request = [urlSchemeTask.request copy]; // todo with context ...... } - (void)webView:(WKWebView *)webView stopURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask API_AVAILABLE(ios(11.0)){ dispatch_async(dispatch_get_main_queue(), ^{ self.holdUrlSchemeTasks[urlSchemeTask.description] = @(FALSE); }); } There is the crash info: #0 Thread SIGSEGV SEGV_ACCERR WebCore void ***::__visitor_table<***::Visitor<WebCore::FormData::resolveBlobReferences(WebCore::BlobRegistryImpl*)::$_8, WebCore::FormData::resolveBlobReferences(WebCore::BlobRegistryImpl*)::$_9, WebCore::FormData::resolveBlobReferences(WebCore::BlobRegistryImpl*)::$_10>, ***::Vector<char, 0ul, ***::CrashOnOverflow, 16ul, ***::FastMalloc>, WebCore::FormDataElement::EncodedFileData, WebCore::FormDataElement::EncodedBlobData>::__trampoline_func<WebCore::FormDataElement::EncodedBlobData>(***::Visitor<WebCore::FormData::resolveBlobReferences(WebCore::BlobRegistryImpl*)::$_8, WebCore::FormData::resolveBlobReferences(WebCore::BlobRegistryImpl*)::$_9, WebCore::FormData::resolveBlobReferences(WebCore::BlobRegistryImpl*)::$_10>&, ***::Variant<***::Vector<char, 0ul, ***::CrashOnOverflow, 16ul, ***::FastMalloc>, WebCore::FormDataElement::EncodedFileData, WebCore::FormDataElement::EncodedBlobData>&) + 68 WebKit::WebURLSchemeTask::nsRequest() const + 68 -[SNADURLSchemeHandler webView:startURLSchemeTask:] (SNADURLSchemeHandler.m:50) Who knows the reason, please help me, thanks!
0
0
109
2w
How to change geolocation settings on WKWebView
We're developing an application using location feature in WKWebView. When accessing a URL that uses location information from WebView, a dialog box saying " Would Like To Use Your Current Location - Don't Allow or OK". If "Dont allow" is selected multiple times, the dialog will disappear and the location setting for that URL will be fixed as "Don't Allow". In Safari, I can change that location settings for each URL, But Application's WebView does not have such settings UI. How do I clear or change the setting so that location information is no longer available? It seems that reinstalling the application will clear the WebView location settings.
0
0
148
2w
Enabling Picture-in-Picture (PiP) in WKWebView
I'm working on a web browser App that's distributed via the App Store. This app renders web pages using WKWebView. Our users are requesting a way for us to allow them to play videos in Picture in Picture. After some investigation, we noticed that in order to allow PiP videos in our browser in the sandboxed environment, we need to add the com.apple.PIPAgent entitlement under the com.apple.security.temporary-exception.mach-lookup.global-name option. We tried to submit our app with this entitlement, but unfortunately, we were rejected: Guideline 2.4.50) - Performance We've determined that one or more temporary entitlement exceptions requested for this app are not appropriate and will not be granted: com.apple.security.temporary-exception.mach-lookup.global-name com.apple.P|PAgent We would like to have access to this entitlement so we can offer PiP to our users. We already created a radar about this as well: FB13814428 Additionally, we have another radar (FB13557716) regarding allowing the usage of a private flag _allowsPictureInPictureMediaPlayback, which would also be required to enable us to use PiP. Is there any way in which we can currently enable PiP? Would opening a TSI help here?
1
11
385
3w
WKWebKit crash - blank screen
We are using a WKWebKit based Cordova application and we are getting WKWebKit crash resulting in blank page. The same web app is working in browser and other platforms. Upon investigation we found the memory used in iOS app using safari debugger / profiler. The total memory used is 870.13 MB. Break up of that is Page: 549MB JavaScript: 321.13MB However, the max comparison for memory shown in safari is 1.37GB while the current usage is 870.13MB. Is there any internal memory calculation for crash cutoff? In this case the current memory is around 62% of the max comparison. Hence, we need to know whether this is the expected behaviour from iOS platform. JetsamEvent-2024-05-23-102822.ips
0
0
210
2w