OpenUrl freezes app for over 10 seconds

前端 未结 11 962
孤街浪徒
孤街浪徒 2020-12-13 02:05

I\'m currently developing an App, that needs to open a browser to display a webpage. To do that i use the [UIApplication sharedApplication] openURL method with

11条回答
  •  [愿得一人]
    2020-12-13 02:24

    Here is the answer in Swift 3.0 with a check to see if we can open the URL or not.

    guard let url = URL(string: myURLString) else {
        return
    }
    
    
    if UIApplication.shared.canOpenURL(url) {
       DispatchQueue.main.async {
         UIApplication.shared.openURL(url)
       }
    }
    

提交回复
热议问题