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

Safari toolbar icon colour ?
I checked the official documentation but I could not see a specific colour to use for the icons sitting in Safari's toolbar (e.g. "toolbar-icon-72"). I have tried a number of different greys and although I have the one that looks good to my eye, it may be a little off to others. So I was wondering if there was a recommended colour ? I also tried using the bundled Digital Colour Meter in macOS to determine a single grey colour, but of course, at the pixel level, anti-aliasing leaves that very much down to interpretation. I have gone with 141/141/141 (RGB).
0
1
271
Nov ’23
WKWebView stops responding when navigating to simple web page that contains external JavaScript
The WKWebView in my application runs flawlessly and executes all the JavaScript of the websites visited. However, if I call up a very simple web page that contains nothing more than a text and a reference to the external JavaScript file "https://code.jquery.com/jquery-3.7.1.min.js", which is nothing unusual, then the WKWebView freezes and no longer responds. The NSAllowArbitaryLoads in Info.plist is set to true. I have checked all configarations and all callbacks of WKNavigationDelegate, but found no way to allow or disallow the external JavaScript. If in my test the JavaScript is loaded from the same server, it works. This is just a test to reproduce the error. I cannot influence the website that I actually want to display in WKWebView.
0
0
330
Nov ’23
Touch event capture method or API for ios
I want to develop the application where I can able to capture and send the touch events like TAP,Press,Swipe etc from iphone to browser(Client) for remote support .can anyone suggest any method or API to capture Touch Events and the method to send on browser. Is there any document or link is available or support for the same
0
0
460
Nov ’23
JavaScript reload of PWA after navigating back from external link
I'm developing a PWA for mobile Safari. Here is a video of the problem that I have: https://share.icloud.com/photos/068xNZvHZqAQI83EP5FHJj8ag I open the app. It's like a Hacker News or Reddit clone so users always navigate away to external links. The external link gets opened in this overlay, which I really like, that's great However, when I press "done", you can see how the page somehow re-evaluates the JavaScript. E.g. the "voting errors" start pulsating which means that the page re-fetches some data from the server, which IMO isn't strictly necessary as the page was fine without that I noticed that this isn't happening if I e.g. have the page open in a tab on regular Safari. When I then navigate to the tab, it doesn't reload JUST the JavaScript What I also find weird about this is that it seems to only reload the JavaScript, not the entire page. My site is at https://news.kiwistand.com/ so you can test this for yourself. The source code of the frontend is here https://github.com/attestate/kiwistand/tree/main/src/web and here's the PWA manifest https://github.com/attestate/kiwistand/blob/main/src/public/pwa.json My question: Is there a way I can stop Safari from "reloading" the JavaScript when navigating back from an external link?
1
1
431
Nov ’23
Safari on MacBook doesn't send http/2 WINDOW_UPDATE frame
Hello Sirs, I've developed http/2 server, tested with nghttpx, Edge, Mozilla, Chrome web browsers, all seems to be fine. As I navigate to an url under my http/2 server with Safari browser (ver 17.^) on MacBook 2023, the server is catching WINDOW_UPDATE frame for stream id 0, but unfortunately no WINDOW_UPDATE frames with specific stream Id are sent from Safari http/2 specification tells, that this frame for stream id 0 isn't yet enough to be allowed to send DATA frames to browser. The concrete stream id is needed in WINDOW_UPDATE frame. The INITIAL_WINDOW_SIZE setting of the SETTINGS frame from Safari is only 100 bytes. I just send the response SETTINGS frame with ACK flag set true, not trying to increase this setting's value. Now the server just sends first DATA frames for each stream, and Safari fetches them, renders and shows in browser, however the streams' window sizes are exhausted. But I'm not risking pushing all DATA frames of larger files, so that other browsers then don't RST these streams. Any infos for me please about specific Safari http/2 frames flow?
2
0
474
Nov ’23
Completion handler passed to -[NSObject webView:decidePolicyForNavigationAction:decisionHandler:] was not called
Hi! I'm having this crash on the app, it only happens in production and I haven't been able to reproduce it. I attacedh the full crash report and here is the code for the decidePolicyForNavigationAction action: func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { guard let url = navigationAction.request.url else { decisionHandler(.allow) return } var policy: WKNavigationActionPolicy = .allow if (["tel", "sms", "facetime"].contains(url.scheme) || navigationAction.navigationType == .linkActivated && initialUrl.host != url.host) && UIApplication.shared.canOpenURL(url) { UIApplication.shared.open(url) policy = .cancel } decisionHandler(policy) } Can someone help me find out what could be then cause for this isse? CrashReport
0
0
462
Nov ’23
WKWebview with external keyboard behaviour
Currently I am using Objective-C and embedding a React website into the WKWebview. I have a component with scroll function and I also have some text description with an input component in the scroll function component. If the input component is shown all and I onClick the input component for inputting value in it, it works normally. However, when the input component shows only half of it and another half is hidden by the scroll component (Because it scrolls to see only half of the input component), it will triggers an unexpected issue that the WKWebview will have a white bar on the bottom and it will keep exists and affecting my UI. I have checked with web inspector that it is outside of the tag. Therefore, seems it is related to the issue with the external keyboard behaviour. Please provide some suggestion if anyone have any idea on this topic. Thanks a lot
0
1
584
Dec ’23
BlockStoragePolicy on Safari
My team is attempting to use an an add-in for Outlook for Mac that stores a Microsoft account access credentials in safari, so that it can refresh the credentials in the background and not force users to manually re-login every time the credentials expire. The update to safari that prevents local storage has prevented this from working correctly. It appears that the local storage prevention policy can be disabled with this command: 'defaults write com.apple.Safari BlockStoragePolicy -bool false' This initially seemed to work but no long seems to be allowing the credentials to be stored. I was unable to find any documentation as to what exactly this command does. I wanted to see if anyone knew exactly what this command does and if there is a variation or alternative command that would make local storage in safari allowed again.
0
0
309
Dec ’23
WKWebView throws RBSServiceError when multiple SwiftUI views are created
Description I've seen this issue when I use WKWebView in SwiftUI. If I have 2 web views at once in a SwiftUI view, it produces unwanted console warnings that seem to be not solvable on client side. The warnings aren't present when there is only 1 web view. Similar warnings regarding the "running board" or RBSAssertionErrorDomain are reported by others as well. Please advice how to dismiss these warnings in the app. Thank you. Repro Steps and Code Create a new iOS project. Put the following code into ContentView.swift. It wraps a WKWebView in SwiftUI and display some dummy html data in the web views. Build and run the app. Tap the info button. Drag down or dismiss the sheet. Upon dismiss, in the console it prints the error messages attached below. import SwiftUI import WebKit struct ContentView: View { @State private var isInfoViewPresented = false @State private var selectedIndex = 0 func makeErrorHTML(index: Int) -> String { #"<!doctype html><html><h1 style="text-align: center;">Unable to display README.</h1></html>"# } var body: some View { VStack(spacing: 8) { Text("Hello, world!") Button { isInfoViewPresented = true } label: { Image(systemName: "info.circle") .imageScale(.large) } .sheet(isPresented: $isInfoViewPresented) { sheetContent } } } var sheetContent: some View { NavigationStack { ZStack { WebView(htmlString: makeErrorHTML(index: 0)) .background(Color(uiColor: .systemGray)) .opacity(selectedIndex == 0 ? 1 : 0) WebView(htmlString: makeErrorHTML(index: 1)) .background(Color(uiColor: .systemGray2)) .opacity(selectedIndex == 1 ? 1 : 0) } .toolbar { ToolbarItem(placement: .principal) { Picker("Information Mode", selection: $selectedIndex) { Text("0").tag(0) Text("1").tag(1) } .pickerStyle(.segmented) } ToolbarItem(placement: .confirmationAction) { Button("Done") { isInfoViewPresented = false } } } } } } struct WebView: UIViewRepresentable { /// The HTML to load in the web view. let htmlString: String func makeUIView(context: Context) -> WKWebView { // Creates an empty web view. let webView = WKWebView(frame: .zero) // Sets the web view's navigation delegate. webView.navigationDelegate = context.coordinator return webView } func updateUIView(_ webView: WKWebView, context: Context) { // Loads the given HTML string. webView.loadHTMLString(htmlString, baseURL: nil) } func makeCoordinator() -> Coordinator { Coordinator() } class Coordinator: NSObject, WKNavigationDelegate { func webView( _ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void ) { switch navigationAction.navigationType { case .linkActivated: if let url = navigationAction.request.url, UIApplication.shared.canOpenURL(url) { UIApplication.shared.open(url) } decisionHandler(.cancel) default: decisionHandler(.allow) } } } } OS Version iOS 15 - iOS 17 Simulator and Device Xcode Version 15.0.1 (15A507) macOS 14.1.1 (23B81) Similar Posts @eskimo shared information about runningboard in this post: https://developer.apple.com/forums/thread/702207 https://developer.apple.com/forums/thread/709919 https://stackoverflow.com/questions/69902932/error-acquiring-assertions-what-is-that https://developer.apple.com/forums/thread/708801 Error From Console 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}> 0x11e024780 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'XPCConnectionTerminationWatchdog' for process with PID=85,796, 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=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}> 0x11e0247e0 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'WebProcess NearSuspended Assertion' for process with PID=85,796, error: Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist} 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}> 0x11e0248a0 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'WebProcess NearSuspended Assertion' for process with PID=85,797, 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}
2
0
3.0k
Dec ’23
Can a WKWebView hosting an "HTTPS" url listen to a "LocalHost WebServer" via a "WebSocket Connection" in an iOS Application?
Problem Description: In the current scenario, I am dealing with a website platform that lacks traditional APIs for service access. To circumvent this limitation, the mobile application necessitates hosting a "web server" locally on "ws://127.0.0.1:****". The idea is that the website, loaded in a WKWebView, should establish a WebSocket connection with the locally hosted server. The responsibility for creating this WebSocket lies with the loaded website. I am utilizing "Telegraph" to set up the local server within the iOS application. To verify the functionality of the local Webserver, I attempted to establish a WebSocket connection to it outside of the WKWebView, and the connection was successfully established. Question: Despite the success of the direct WebSocket connection outside of WKWebView, I am encountering difficulties when attempting to establish the same connection within the WKWebView. Is this approach even feasible? If it is, could you kindly point out any potential oversights or provide guidance on what might be missing in my implementation? Your assistance in resolving this matter is greatly appreciated.
0
0
628
Dec ’23
iOS Web Apps - Notification.permission reports as "default", after tapping on a notification that uses clients.openWindow
One Line Summary Notification.permission is incorrectly reported as "default" on iOS App Webs, this happens when tapping on a notification that results in a new "window" being opened via clients.openWindow. Why this is is important to fix This is confusing to the end-user as sites will check Notification.permission and see it is "default" and then attempt to show the end-user a soft notification permission prompt again. Steps to reproduce the issue On a iOS 16.4 or newer device open https://ios-webapp-notification-new-window-permission-bug.glitch.me in Safari Tap share button Tap "Add to Home Screen" Open the iOS Web App you just added Tap "Prompt Notification permission" On the iOS native notification permission prompt press "Allow" Tap "Display notification" Tap on the notification [Safari/iOS Bug] Observe Notification.permission reports as "default" when it should be "granted" What devices are affected I have reproduce this issue on an iPhone 14 Pro on both iOS 16.7.2 & 17.1.2. However I would expect all iOS 16.4+ devices to be effected.
0
1
541
Dec ’23
How to release a JSValueRef created by JSObjectMakeTypedArrayWithBytesNoCopy?
Hi I use JSObjectMakeTypedArrayWithBytesNoCopy(JSContextRef ctx, JSTypedArrayType arrayType, void *bytes, size_t byteLength, JSTypedArrayBytesDeallocator bytesDeallocator, void *deallocatorContext, JSValueRef *exception) to create a JSObjectRef, and [JSValue valueWithJSValueRef: inContext:] to create a JSValue. I then pass the JSValue to the JSContext. I have noticed that even if I don't pass the JSValue to the JSContext, the JSTypedArrayBytesDeallocator is always called after the deallocation of the JSContext. In my understanding, it should be released by the JS garbage collection when there are no references to it. Since I have a large amount of data to pass to the JSContext, if the JSTypedArrayBytesDeallocator is called too late, it may cause memory issues. Where am I mistaken in this case? Thanks.
0
0
485
Dec ’23