Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open with Universal Links when possible #101

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ViteMaDose/Helpers/Extensions/Data+Commons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extension Data {
/// - Parameter type: Object type
func decode<T: Codable>(_ type: T.Type) -> Result<T, Error> {
let jsonDecoder = JSONDecoder()

do {
let decoded = try jsonDecoder.decode(T.self, from: self)
return .success(decoded)
Expand Down
13 changes: 9 additions & 4 deletions ViteMaDose/Views/CentresList/CentresListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@ class CentresListViewController: UIViewController, Storyboarded {

private func openBookingUrl(_ url: URL?) {
guard let url = url else { return }
let config = SFSafariViewController.Configuration()
let safariViewController = SFSafariViewController(url: url, configuration: config)
Haptic.impact(.light).generate()
present(safariViewController, animated: true)
UIApplication.shared.open(url, options: [.universalLinksOnly: true]) { (success) in
nathanfallet marked this conversation as resolved.
Show resolved Hide resolved
Haptic.impact(.light).generate()
if !success {
// Opening the Universal Link did not work, opening in SFSafariWebViewController instead
let config = SFSafariViewController.Configuration()
let safariViewController = SFSafariViewController(url: url, configuration: config)
self.present(safariViewController, animated: true)
}
}
}

private func openPhoneNumberUrl(_ url: URL?) {
Expand Down