Looking to open a link via UIApplication.shared.open in Swift4, Xcode9, I'm trying to use a completion block as is standard now, the most common stackoverflow answer is:
UIApplication.shared.open(url, options: [:],
completionHandler: {
(success) in
print("returned")
})
You don't have to return any value and your code should work as it is. You just need to check if the browser was launched or not as follow:
let url = URL(string: "https://www.google.com")!
UIApplication.shared.open(url) { success in
if success {
print("browser successfuly opened")
}
}