Skip to content

Instantly share code, notes, and snippets.

@Ariandr
Created May 15, 2018 13:08
Show Gist options
  • Select an option

  • Save Ariandr/ff29c8cf79b5eeb415d6f14d269c8bad to your computer and use it in GitHub Desktop.

Select an option

Save Ariandr/ff29c8cf79b5eeb415d6f14d269c8bad to your computer and use it in GitHub Desktop.
In order to open an app or a website (if the app is not available)
extension UIApplication {
class func tryURL(urls: [String]) {
let application = UIApplication.shared
for url in urls {
guard let url = URL(string: url) else {
continue
}
if application.canOpenURL(url) {
application.open(url, options: [:], completionHandler: nil)
return
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment