2016-11-14 69 views

回答

2

打開一個URL只是檢查使用canOpenURL(_:)

雨燕3.0

if (UIApplication.shared.canOpenURL(URL(string:"twitter://"))) { 
    print("Twitter is installed") 
} 

雨燕2.3或更低

if (UIApplication.sharedApplication().canOpenURL(NSURL(string:"twitter://"))) { 
    print("Twitter is installed") 
} 
+0

非常感謝,它的工作原理 – Kirill

0

你可以嘗試檢查,如果應用程序可以在該應用程序

extension UIApplication { 
     class func tryURL(_ urls: [String]) { 
      let application = UIApplication.shared 
      for urlString in urls { 
       if let url = URL(string: urlString) { 
        if application.canOpenURL(url) { 
         //Do your stuff 
        } 
       } 
      } 
     } 
    } 
相關問題