Skip to content

Instantly share code, notes, and snippets.

@rldaulton
Created February 28, 2019 19:59
Show Gist options
  • Save rldaulton/c544b7fcb49a4c789812b4089f061f06 to your computer and use it in GitHub Desktop.
Save rldaulton/c544b7fcb49a4c789812b4089f061f06 to your computer and use it in GitHub Desktop.
You should always check if a link is univeral, before opening it in any browser session of SFSafariView
let url = URL(string: "https://youtu.be/5IVsLLlRNXc")!
UIApplication.shared.open(url, options: [.universalLinksOnly: true]) { (success) in
if !success {
// not a universal link or app not installed
let vc = SFSafariViewController(url: url)
self.present(vc, animated: true)
}
}
@phansen-nd
Copy link

This seems like a good practice, but when I add this, success is always returning false, even for links that match a path in our AASA file and that open the app successfully when tapped from outside the app. Have you encountered this issue?

@rldaulton
Copy link
Author

@phansen-nd I have not, personally. But also, this code is many years old. There might be a better way to do this by now.

However, is your AASA being served over HTTPS? I think iOS will only retrieve it over a secure connection. You should be able to verify your AASA file with this tool.

@phansen-nd
Copy link

Yeah the file looks okay with that tool. Just thought I'd check - thanks anyway!

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