From ad72b01ea00902a1ea347555cdab6db33b8dd878 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 5 Jul 2026 13:19:38 -0700 Subject: [PATCH] Open GitHub links in settings in GitHub app when installed. --- iOS/Settings/SettingsViewController.swift | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/iOS/Settings/SettingsViewController.swift b/iOS/Settings/SettingsViewController.swift index 2e10b1f04..8aecf7a3d 100644 --- a/iOS/Settings/SettingsViewController.swift +++ b/iOS/Settings/SettingsViewController.swift @@ -576,7 +576,25 @@ private extension SettingsViewController { } func openURL(_ urlString: String) { - let vc = SFSafariViewController(url: URL(string: urlString)!) + guard let url = URL(string: urlString) else { + return + } + + // Open GitHub links in the GitHub app when installed. + if let host = url.host, host == "github.com" || host.hasSuffix(".github.com") { + UIApplication.shared.open(url, options: [.universalLinksOnly: true]) { [weak self] openedInApp in + if !openedInApp { + self?.presentSafariViewController(for: url) + } + } + return + } + + presentSafariViewController(for: url) + } + + private func presentSafariViewController(for url: URL) { + let vc = SFSafariViewController(url: url) vc.modalPresentationStyle = .pageSheet present(vc, animated: true) }