Skip to content

Commit 95cf248

Browse files
author
Alexander Mokrushin
committed
Added comments
1 parent 42e98fa commit 95cf248

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Package contains SDK to use camera torch from page loaded to WKWebView.
44

55
## Installation
6-
Install Swift-package as it's shown below:
76
Add WebViewSDK using the Package manager in Xcode. Use the URL `https://github.com/Transported-Labs/ios-webview-sdk`
87
![](images/install.png)
98

Sources/WebViewSDK/WebViewController.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ public class WebViewController: UIViewController, WKNavigationDelegate, WKUIDele
3232

3333
webView.navigationDelegate = self
3434
webView.uiDelegate = self
35+
// Adding control for reload web-page on pull down
3536
let refreshControl = UIRefreshControl()
3637
refreshControl.addTarget(self, action: #selector(reloadWebView(_:)), for: .valueChanged)
3738
webView.scrollView.addSubview(refreshControl)
39+
// Adding cueSDK scripting object
3840
webView.configuration.defaultWebpagePreferences.allowsContentJavaScript = true
3941
let contentController = self.webView.configuration.userContentController
4042
contentController.add(self, name: cueSDKName)
4143
}
4244

45+
/// Navigates to the url in embedded WKWebView-object
4346
public func navigateTo(url: URL) throws {
4447
if UIApplication.shared.canOpenURL(url) {
4548
webView.load(URLRequest(url: url))
@@ -48,6 +51,7 @@ public class WebViewController: UIViewController, WKNavigationDelegate, WKUIDele
4851
}
4952
}
5053

54+
/// Navigates to the local file url in embedded WKWebView-object
5155
public func navigateToFile(url: URL) {
5256
webView.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent())
5357
}
@@ -179,7 +183,7 @@ extension WebViewController: WKScriptMessageHandler{
179183
let js2:String = "cueSDKCallback(JSON.stringify(\(paramData)))"
180184
print("Sent to Javascript: \(js2)")
181185
self.webView.evaluateJavaScript(js2, completionHandler: { (result, error) -> Void in
182-
print(error?.localizedDescription ?? "Sent successfully, no error")
186+
print(error?.localizedDescription ?? "Sent successfully, no errors")
183187
})
184188
}
185189
} else {

0 commit comments

Comments
 (0)