Summary
When a SwiftUI widget uses a Link containing an Image modified with .widgetAccentedRenderingMode (using any mode except .fullColor), tapping the image on the widget launches the app but does not pass the expected deep link URL to the SceneDelegate.
Steps to Reproduce
Create a SwiftUI Widget View with a Link:
struct ImageView: View {
var image: UIImage
var body: some View {
Link(URL(string: "myapp://image")!) {
Image(uiImage: image)
.resizable()
.widgetAccentedRenderingMode(.accentedDesaturated) // or any mode other than .fullColor
.scaledToFill()
.clipped()
}
}
}
Add Custom URL Scheme in Info.plist:
<dict>
<key>CFBundleURLName</key>
<string>com.company.myapp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp</string>
</array>
</dict>
Implement Deep Link Handling in SceneDelegate:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
if let url = connectionOptions.urlContexts.first?.url {
handle(url)
}
}
func scene(_ scene: UIScene, openURLContexts urlContexts: Set<UIOpenURLContext>) {
if let url = urlContexts.first?.url {
handle(url)
}
}
private func handle(_ url: URL) {
// Process URL here
}
Run the application on a device or simulator.
Add the widget to the Home Screen.
Tap the image inside the widget.
Expected Result
The application launches and receives the URL in SceneDelegate, as expected.
Actual Result
The application launches, but the URL is not passed to SceneDelegate.
Both connectionOptions.urlContexts and openURLContexts are empty.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Something has changed in iOS 26 and now if custom scheme is used and web page contains scripts WebKit is terminated.
0x1130bc170 - [PID=47858] WebProcessProxy::didClose: (web process 0 crash)
0x1130bc170 - [PID=47858] WebProcessProxy::processDidTerminateOrFailedToLaunch: reason=Crash
final class CustomSchemeViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let sampleConfiguration = WKWebViewConfiguration()
sampleConfiguration.setURLSchemeHandler(
SampleURLSchemeHandler(),
forURLScheme: "sample"
)
let webView = WKWebView(frame: view.bounds, configuration: sampleConfiguration)
webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(webView)
webView.navigationDelegate = self
webView.load(URLRequest(url: URL(string: "sample://pages/sample.html")!))
}
}
extension CustomSchemeViewController: WKNavigationDelegate {
func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
print("webViewWebContentProcessDidTerminate")
}
}
final class SampleURLSchemeHandler: NSObject, WKURLSchemeHandler {
private func post(_ body: String, mimeType: String, urlSchemeTask: WKURLSchemeTask) {
let body = Data(body.utf8)
let response = URLResponse(
url: urlSchemeTask.request.url!,
mimeType: mimeType,
expectedContentLength: body.count,
textEncodingName: nil
)
urlSchemeTask.didReceive(response)
urlSchemeTask.didReceive(body)
urlSchemeTask.didFinish()
}
func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) {
switch urlSchemeTask.request.url?.lastPathComponent {
case "sample.html":
post("""
<?xml version="1.0" encoding="UTF-8"?><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="/scripts/sample.js"></script>
</head>
<body>
<p>Sample</p>
</body>
</html>
""",
mimeType: "application/xhtml+xml",
urlSchemeTask: urlSchemeTask
)
case "sample.js":
post("console.log('Hello from JS File')",
mimeType: "text/javascript",
urlSchemeTask: urlSchemeTask
)
default:
assertionFailure()
}
}
func webView(_ webView: WKWebView, stop urlSchemeTask: WKURLSchemeTask) {
print("webView(_ webView: WKWebView, stop urlSchemeTask: WKURLSchemeTask)")
}
}
It works fine with css file inside, without script tag or with async attribute
Code of sample project https://github.com/Igor-Palaguta/iOS26URLSchemeTermination