Created
May 15, 2018 13:08
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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