diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..820432a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,20 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0-beta.1] - 2021-05-12 +### Added +- WKUIDelegate method implementation to open share links in default browser. + +## [1.0.0-beta] - 2021-05-07 +### Added +- Base functionality for rendering a widget in a managed WKWebView. +- SaaSquatch API methods for `graphql`, `renderWidget`, `upsertWidget`, `logUserEvent`, `pushWidgetLoadedAnalyticEvent`, and `pushWidgetSharedAnalyticEvent`. + +[Unreleased]: https://github.com/saasquatch/squatch-ios/compare/v1.0.0-beta.1...HEAD +[1.0.0-beta.1]: https://github.com/saasquatch/squatch-ios/compare/v1.0.0-beta...v1.0.0-beta.1 +[1.0.0-beta]: https://github.com/saasquatch/squatch-ios/releases/tag/v1.0.0-beta diff --git a/Example/Example/ContentView.swift b/Example/Example/ContentView.swift index f4376c7..033f120 100644 --- a/Example/Example/ContentView.swift +++ b/Example/Example/ContentView.swift @@ -54,7 +54,7 @@ class WebViewController: UIViewController { super.viewDidLoad() let jwt = "" - + do { let input = try WidgetUpsertInput.Builder() .setUserInputWithUserJwt(jwt) diff --git a/Sources/SaaSquatchWebView/SaaSquatchWebView.swift b/Sources/SaaSquatchWebView/SaaSquatchWebView.swift index ad98964..753ce47 100644 --- a/Sources/SaaSquatchWebView/SaaSquatchWebView.swift +++ b/Sources/SaaSquatchWebView/SaaSquatchWebView.swift @@ -3,7 +3,7 @@ import SwiftyJSON import WebKit import SaaSquatch -public class SaaSquatchWebView: WKWebView { +public class SaaSquatchWebView: WKWebView, WKUIDelegate { public var client: SaaSquatchClient? /** @@ -85,6 +85,7 @@ public class SaaSquatchWebView: WKWebView { private func setWebViewContent(html: String) { DispatchQueue.main.async { + self.uiDelegate = self let htmlWithMeta = html.replacingOccurrences(of: "", with: "") self.loadHTMLString(htmlWithMeta, baseURL: URL(string: "https://fast.ssqt.io")) } @@ -114,6 +115,18 @@ public class SaaSquatchWebView: WKWebView { } } } + + public func webView(_ webView: WKWebView, + createWebViewWith configuration: WKWebViewConfiguration, + for navigationAction: WKNavigationAction, + windowFeatures: WKWindowFeatures) -> WKWebView? { + if let url = navigationAction.request.url, navigationAction.targetFrame == nil { + if url.scheme == "http" || url.scheme == "https" || url.scheme == "mailto" { + UIApplication.shared.open(url) + } + } + return nil + } } let ERROR_HTML_TEMPLATE = """