 
 import SafariServices
 
+
+extension UIApplication {
+    func number_canOpenURL(url:NSURL) -> NSNumber {
+        return NSNumber(bool: canOpenURL(url))
+    }
+}
+
 public extension UIViewController {
     
     

    */
    public func openInSafari(url:NSURL) {
        
        #if TD_APP_EXTENSION
            
            if #available(iOS 9, *) {
                
                let vc = SFSafariViewController(URL: url)
                vc.delegate = self
                self.presentViewController(vc, animated: true, completion: nil)
                
            }
            
        #else
            
            if #available(iOS 9, *) {
                
                let vc = SFSafariViewController(URL: url)
                vc.delegate = self
                self.presentViewController(vc, animated: true, completion: nil)
                
            } else if UIApplication.sharedApplication().canOpenURL(url) {
                UIApplication.sharedApplication().openURL(url)
            }
        
        #endif
    }
    

    public func safariViewControllerDidFinish(controller: SFSafariViewController) {
        controller.dismissViewControllerAnimated(true, completion: nil)
    }
    
    public func openURLUsingResponder(url:NSURL) {
        
        var responder = self.nextResponder()
        while responder != nil {
            
            if responder is UIApplication {
                break
            } else {
                responder = responder?.nextResponder()
            }
        }
        
        if let application = responder as? UIApplication {
            application.performSelector("openURL:", withObject: url)
            return
        }
    }
    
    public func canOpenURL(url:NSURL) -> Bool {
        
        #if TD_APP_EXTENSION
            return canOpenURLUsingResponder(url) ?? false
        #else
            return UIApplication.sharedApplication().canOpenURL(url)
        #endif
    }
    
    public func openURL(url:NSURL) {
        
        #if TD_APP_EXTENSION
            return openURLUsingResponder(url)
        #else
            return UIApplication.sharedApplication().openURL(url)
        #endif
    }
    
    public func canOpenURLUsingResponder(url:NSURL) -> Bool? {
        
        var responder = self.nextResponder()
        while responder != nil {
            
            if responder is UIApplication {
                break
            } else {
                responder = responder?.nextResponder()
            }
        }
        
        if let application = responder as? UIApplication {
            let result = application.performSelector("number_canOpenURL:", withObject: url)
            return result?.takeUnretainedValue() as? Bool
        }
        
        return false
    }
}