diff --git a/Example/SwiftWebVCExample.xcodeproj/project.xcworkspace/xcuserdata/myles.xcuserdatad/UserInterfaceState.xcuserstate b/Example/SwiftWebVCExample.xcodeproj/project.xcworkspace/xcuserdata/myles.xcuserdatad/UserInterfaceState.xcuserstate index 50c7ff7..5363dc4 100644 Binary files a/Example/SwiftWebVCExample.xcodeproj/project.xcworkspace/xcuserdata/myles.xcuserdatad/UserInterfaceState.xcuserstate and b/Example/SwiftWebVCExample.xcodeproj/project.xcworkspace/xcuserdata/myles.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Example/SwiftWebVCExample/ViewController.swift b/Example/SwiftWebVCExample/ViewController.swift index 2094097..c0ebd5a 100644 --- a/Example/SwiftWebVCExample/ViewController.swift +++ b/Example/SwiftWebVCExample/ViewController.swift @@ -34,12 +34,12 @@ class ViewController: UIViewController { } @IBAction func presentModalWithLightBlackTheme() { - let webVC = SwiftModalWebVC(urlString: "https://www.google.com", theme: .lightBlack) + let webVC = SwiftModalWebVC(urlString: "https://www.google.com", theme: .lightBlack, dismissButtonStyle: .cross) self.present(webVC, animated: true, completion: nil) } @IBAction func presentModalWithDarkTheme() { - let webVC = SwiftModalWebVC(urlString: "https://www.google.com", theme: .dark) + let webVC = SwiftModalWebVC(urlString: "https://www.google.com", theme: .dark, dismissButtonStyle: .arrow) self.present(webVC, animated: true, completion: nil) } diff --git a/README.md b/README.md index 488f452..22ebd38 100755 --- a/README.md +++ b/README.md @@ -117,3 +117,5 @@ Starting in iOS 6 Apple uses `UIActivity` to let you show additional sharing met SwiftWebVC is a Swift implementation of [Sam Vermette's SVWebViewController](https://github.com/samvermette/SVWebViewController/). Code transcription, updates and changes were carried out by Myles Ringle. The original SVWebViewController was brought to you by [Sam Vermette](http://samvermette.com) and [contributors to the project](https://github.com/samvermette/SVWebViewController/contributors). If you have feature suggestions or bug reports, feel free to help out by sending pull requests or by [creating new issues](https://github.com/meismyles/SwiftWebVC/issues/new). If you're using SwiftWebVC in your project, attribution is always appreciated. + +Thanks to [Icons8](https://icons8.com/) for the images. diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome-iPad.imageset/SwiftWebVCActivityChrome-iPad.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome-iPad.imageset/SwiftWebVCActivityChrome-iPad.png deleted file mode 100755 index cd19edb..0000000 Binary files a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome-iPad.imageset/SwiftWebVCActivityChrome-iPad.png and /dev/null differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome-iPad.imageset/SwiftWebVCActivityChrome-iPad@2x.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome-iPad.imageset/SwiftWebVCActivityChrome-iPad@2x.png deleted file mode 100755 index 5c8b081..0000000 Binary files a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome-iPad.imageset/SwiftWebVCActivityChrome-iPad@2x.png and /dev/null differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/Contents.json b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/Contents.json old mode 100755 new mode 100644 index af4a561..e2c9eb1 --- a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/Contents.json +++ b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/Contents.json @@ -2,6 +2,7 @@ "images" : [ { "idiom" : "universal", + "filename" : "SwiftWebVCActivityChrome.png", "scale" : "1x" }, { @@ -11,6 +12,7 @@ }, { "idiom" : "universal", + "filename" : "SwiftWebVCActivityChrome@3x.png", "scale" : "3x" } ], diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/SwiftWebVCActivityChrome.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/SwiftWebVCActivityChrome.png new file mode 100644 index 0000000..b8b4f45 Binary files /dev/null and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/SwiftWebVCActivityChrome.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/SwiftWebVCActivityChrome@2x.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/SwiftWebVCActivityChrome@2x.png old mode 100755 new mode 100644 index 565e0ce..88712b8 Binary files a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/SwiftWebVCActivityChrome@2x.png and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/SwiftWebVCActivityChrome@2x.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/SwiftWebVCActivityChrome@3x.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/SwiftWebVCActivityChrome@3x.png new file mode 100644 index 0000000..d750db2 Binary files /dev/null and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome.imageset/SwiftWebVCActivityChrome@3x.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari-iPad.imageset/Contents.json b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari-iPad.imageset/Contents.json deleted file mode 100755 index 4c57f84..0000000 --- a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari-iPad.imageset/Contents.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "filename" : "SwiftWebVCActivitySafari-iPad.png", - "scale" : "1x" - }, - { - "idiom" : "universal", - "filename" : "SwiftWebVCActivitySafari-iPad@2x.png", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari-iPad.imageset/SwiftWebVCActivitySafari-iPad.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari-iPad.imageset/SwiftWebVCActivitySafari-iPad.png deleted file mode 100755 index 31f2ca8..0000000 Binary files a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari-iPad.imageset/SwiftWebVCActivitySafari-iPad.png and /dev/null differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari-iPad.imageset/SwiftWebVCActivitySafari-iPad@2x.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari-iPad.imageset/SwiftWebVCActivitySafari-iPad@2x.png deleted file mode 100755 index 856e4d0..0000000 Binary files a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari-iPad.imageset/SwiftWebVCActivitySafari-iPad@2x.png and /dev/null differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/Contents.json b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/Contents.json old mode 100755 new mode 100644 index 788ec73..315cd0f --- a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/Contents.json +++ b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/Contents.json @@ -2,6 +2,7 @@ "images" : [ { "idiom" : "universal", + "filename" : "SwiftWebVCActivitySafari.png", "scale" : "1x" }, { @@ -11,6 +12,7 @@ }, { "idiom" : "universal", + "filename" : "SwiftWebVCActivitySafari@3x.png", "scale" : "3x" } ], diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/SwiftWebVCActivitySafari.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/SwiftWebVCActivitySafari.png new file mode 100644 index 0000000..d5dcdeb Binary files /dev/null and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/SwiftWebVCActivitySafari.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/SwiftWebVCActivitySafari@2x.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/SwiftWebVCActivitySafari@2x.png old mode 100755 new mode 100644 index b0dc8c7..09bc2f4 Binary files a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/SwiftWebVCActivitySafari@2x.png and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/SwiftWebVCActivitySafari@2x.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/SwiftWebVCActivitySafari@3x.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/SwiftWebVCActivitySafari@3x.png new file mode 100644 index 0000000..5bf4fd4 Binary files /dev/null and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivitySafari.imageset/SwiftWebVCActivitySafari@3x.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/Contents.json b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/Contents.json old mode 100755 new mode 100644 index 20450d1..b615372 --- a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/Contents.json +++ b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/Contents.json @@ -12,6 +12,7 @@ }, { "idiom" : "universal", + "filename" : "SwiftWebVCBack@3x.png", "scale" : "3x" } ], diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/SwiftWebVCBack.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/SwiftWebVCBack.png old mode 100755 new mode 100644 index 195b4fd..e92a7a5 Binary files a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/SwiftWebVCBack.png and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/SwiftWebVCBack.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/SwiftWebVCBack@2x.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/SwiftWebVCBack@2x.png old mode 100755 new mode 100644 index e677e23..46e8de5 Binary files a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/SwiftWebVCBack@2x.png and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/SwiftWebVCBack@2x.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/SwiftWebVCBack@3x.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/SwiftWebVCBack@3x.png new file mode 100644 index 0000000..7012936 Binary files /dev/null and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCBack.imageset/SwiftWebVCBack@3x.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/Contents.json b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/Contents.json old mode 100755 new mode 100644 index ded2772..74952bc --- a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/Contents.json +++ b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/Contents.json @@ -12,6 +12,7 @@ }, { "idiom" : "universal", + "filename" : "SwiftWebVCDismiss@3x.png", "scale" : "3x" } ], diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/SwiftWebVCDismiss.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/SwiftWebVCDismiss.png old mode 100755 new mode 100644 index a7a374d..9731e80 Binary files a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/SwiftWebVCDismiss.png and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/SwiftWebVCDismiss.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/SwiftWebVCDismiss@2x.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/SwiftWebVCDismiss@2x.png old mode 100755 new mode 100644 index 91d5e09..8546948 Binary files a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/SwiftWebVCDismiss@2x.png and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/SwiftWebVCDismiss@2x.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/SwiftWebVCDismiss@3x.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/SwiftWebVCDismiss@3x.png new file mode 100644 index 0000000..3c4f364 Binary files /dev/null and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismiss.imageset/SwiftWebVCDismiss@3x.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome-iPad.imageset/Contents.json b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismissAlt.imageset/Contents.json old mode 100755 new mode 100644 similarity index 64% rename from SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome-iPad.imageset/Contents.json rename to SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismissAlt.imageset/Contents.json index f1f8901..47e0b38 --- a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCActivityChrome-iPad.imageset/Contents.json +++ b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismissAlt.imageset/Contents.json @@ -2,16 +2,17 @@ "images" : [ { "idiom" : "universal", - "filename" : "SwiftWebVCActivityChrome-iPad.png", + "filename" : "SwiftWebVCDismissAlt.png", "scale" : "1x" }, { "idiom" : "universal", - "filename" : "SwiftWebVCActivityChrome-iPad@2x.png", + "filename" : "SwiftWebVCDismissAlt@2x.png", "scale" : "2x" }, { "idiom" : "universal", + "filename" : "SwiftWebVCDismissAlt@3x.png", "scale" : "3x" } ], diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismissAlt.imageset/SwiftWebVCDismissAlt.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismissAlt.imageset/SwiftWebVCDismissAlt.png new file mode 100644 index 0000000..416ccae Binary files /dev/null and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismissAlt.imageset/SwiftWebVCDismissAlt.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismissAlt.imageset/SwiftWebVCDismissAlt@2x.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismissAlt.imageset/SwiftWebVCDismissAlt@2x.png new file mode 100644 index 0000000..b2fa8bc Binary files /dev/null and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismissAlt.imageset/SwiftWebVCDismissAlt@2x.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismissAlt.imageset/SwiftWebVCDismissAlt@3x.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismissAlt.imageset/SwiftWebVCDismissAlt@3x.png new file mode 100644 index 0000000..ea7ac61 Binary files /dev/null and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCDismissAlt.imageset/SwiftWebVCDismissAlt@3x.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/Contents.json b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/Contents.json old mode 100755 new mode 100644 index eca6582..90388df --- a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/Contents.json +++ b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/Contents.json @@ -12,6 +12,7 @@ }, { "idiom" : "universal", + "filename" : "SwiftWebVCNext@3x.png", "scale" : "3x" } ], diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/SwiftWebVCNext.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/SwiftWebVCNext.png old mode 100755 new mode 100644 index 453bc79..b1121b2 Binary files a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/SwiftWebVCNext.png and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/SwiftWebVCNext.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/SwiftWebVCNext@2x.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/SwiftWebVCNext@2x.png old mode 100755 new mode 100644 index 5746bec..3ee8c43 Binary files a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/SwiftWebVCNext@2x.png and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/SwiftWebVCNext@2x.png differ diff --git a/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/SwiftWebVCNext@3x.png b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/SwiftWebVCNext@3x.png new file mode 100644 index 0000000..271bdcd Binary files /dev/null and b/SwiftWebVC/Resources/Media.xcassets/SwiftWebVCNext.imageset/SwiftWebVCNext@3x.png differ diff --git a/SwiftWebVC/SwiftModalWebVC.swift b/SwiftWebVC/SwiftModalWebVC.swift index 729b3cb..de3e649 100755 --- a/SwiftWebVC/SwiftModalWebVC.swift +++ b/SwiftWebVC/SwiftModalWebVC.swift @@ -13,6 +13,9 @@ public class SwiftModalWebVC: UINavigationController { public enum SwiftModalWebVCTheme { case lightBlue, lightBlack, dark } + public enum SwiftModalWebVCDismissButtonStyle { + case arrow, cross + } weak var webViewDelegate: UIWebViewDelegate? = nil @@ -20,23 +23,24 @@ public class SwiftModalWebVC: UINavigationController { self.init(pageURL: URL(string: urlString)!) } - public convenience init(urlString: String, theme: SwiftModalWebVCTheme) { - self.init(pageURL: URL(string: urlString)!, theme: theme) + public convenience init(urlString: String, theme: SwiftModalWebVCTheme, dismissButtonStyle: SwiftModalWebVCDismissButtonStyle) { + self.init(pageURL: URL(string: urlString)!, theme: theme, dismissButtonStyle: dismissButtonStyle) } public convenience init(pageURL: URL) { self.init(request: URLRequest(url: pageURL)) } - public convenience init(pageURL: URL, theme: SwiftModalWebVCTheme) { - self.init(request: URLRequest(url: pageURL), theme: theme) + public convenience init(pageURL: URL, theme: SwiftModalWebVCTheme, dismissButtonStyle: SwiftModalWebVCDismissButtonStyle) { + self.init(request: URLRequest(url: pageURL), theme: theme, dismissButtonStyle: dismissButtonStyle) } - public init(request: URLRequest, theme: SwiftModalWebVCTheme = .lightBlue) { + public init(request: URLRequest, theme: SwiftModalWebVCTheme = .lightBlue, dismissButtonStyle: SwiftModalWebVCDismissButtonStyle = .arrow) { let webViewController = SwiftWebVC(aRequest: request) webViewController.storedStatusColor = UINavigationBar.appearance().barStyle - - let doneButton = UIBarButtonItem(image: SwiftWebVC.bundledImage(named: "SwiftWebVCDismiss"), + + let dismissButtonImageName = (dismissButtonStyle == .arrow) ? "SwiftWebVCDismiss" : "SwiftWebVCDismissAlt" + let doneButton = UIBarButtonItem(image: SwiftWebVC.bundledImage(named: dismissButtonImageName), style: UIBarButtonItemStyle.plain, target: webViewController, action: #selector(SwiftWebVC.doneButtonTapped)) diff --git a/SwiftWebVC/SwiftWebVC.swift b/SwiftWebVC/SwiftWebVC.swift index 502ea3b..3ddc9c1 100755 --- a/SwiftWebVC/SwiftWebVC.swift +++ b/SwiftWebVC/SwiftWebVC.swift @@ -306,5 +306,59 @@ extension SwiftWebVC: WKNavigationDelegate { updateToolbarItems() } + public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { + + + let url = navigationAction.request.url + + let hostAddress = navigationAction.request.url?.host + + if (navigationAction.targetFrame == nil) { + if UIApplication.shared.canOpenURL(url!) { + UIApplication.shared.openURL(url!) + } + } + decisionHandler(.allow) + + // To connnect app store + if hostAddress == "itunes.apple.com" { + if UIApplication.shared.canOpenURL(navigationAction.request.url!) { + UIApplication.shared.openURL(navigationAction.request.url!) + decisionHandler(.cancel) + return + } + } + + let url_elements = url!.absoluteString.components(separatedBy: ":") + + switch url_elements[0] { + case "tel": + openCustomApp(urlScheme: "telprompt://", additional_info: url_elements[1]) + decisionHandler(.cancel) + + case "sms": + openCustomApp(urlScheme: "sms://", additional_info: url_elements[1]) + decisionHandler(.cancel) + + case "mailto": + openCustomApp(urlScheme: "mailto://", additional_info: url_elements[1]) + decisionHandler(.cancel) + + default: + print("Default") + } + + decisionHandler(.allow) + + } + func openCustomApp(urlScheme: String, additional_info:String){ + + if let requestUrl: URL = URL(string:"\(urlScheme)"+"\(additional_info)") { + let application:UIApplication = UIApplication.shared + if application.canOpenURL(requestUrl) { + application.openURL(requestUrl) + } + } + } } diff --git a/SwiftWebVC/SwiftWebVCActivity.swift b/SwiftWebVC/SwiftWebVCActivity.swift index 4954df1..f3367aa 100755 --- a/SwiftWebVC/SwiftWebVCActivity.swift +++ b/SwiftWebVC/SwiftWebVCActivity.swift @@ -22,12 +22,7 @@ class SwiftWebVCActivity: UIActivity { override var activityImage : UIImage { if let type = activityType?.rawValue { - if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad) { - return SwiftWebVC.bundledImage(named: "\(type)-iPad")! - } - else { - return SwiftWebVC.bundledImage(named: "\(type)")! - } + return SwiftWebVC.bundledImage(named: "\(type)")! } else{ assert(false, "Unknow type")