Skip to content

Instantly share code, notes, and snippets.

@kevenbauke
Last active June 21, 2022 17:13
Show Gist options
  • Save kevenbauke/d449718a5f268ee843f286db88f137cc to your computer and use it in GitHub Desktop.
Save kevenbauke/d449718a5f268ee843f286db88f137cc to your computer and use it in GitHub Desktop.
WKWebView open links in Safari
@kevenbauke
Copy link
Author

@raymond-1227 if you want want to detect magnet-links you can use a similar approach as how this code detects the links. You can use the scheme attribute of the URLComponent.

if components?.scheme == "magnet" {
    // Do whatever you want.
}

@raymond-1227
Copy link

I tried the method, but I'm not sure why if I use the code, it'll say WebPageProxy::didFailProvisionalLoadForFrame: frameID=575, domain=NSURLErrorDomain, code=-999 when the code was set like this:

if components?.scheme == "roblox-player" {
      decisionHandler(.allow)
}

I think the error was dedicated to the custom scheme, because if I use webview.uiDelegate (which doesn't handle external links) the error doesn't appear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment