@@ -32,14 +32,17 @@ public class WebViewController: UIViewController, WKNavigationDelegate, WKUIDele
32
32
33
33
webView. navigationDelegate = self
34
34
webView. uiDelegate = self
35
+ // Adding control for reload web-page on pull down
35
36
let refreshControl = UIRefreshControl ( )
36
37
refreshControl. addTarget ( self , action: #selector( reloadWebView ( _: ) ) , for: . valueChanged)
37
38
webView. scrollView. addSubview ( refreshControl)
39
+ // Adding cueSDK scripting object
38
40
webView. configuration. defaultWebpagePreferences. allowsContentJavaScript = true
39
41
let contentController = self . webView. configuration. userContentController
40
42
contentController. add ( self , name: cueSDKName)
41
43
}
42
44
45
+ /// Navigates to the url in embedded WKWebView-object
43
46
public func navigateTo( url: URL ) throws {
44
47
if UIApplication . shared. canOpenURL ( url) {
45
48
webView. load ( URLRequest ( url: url) )
@@ -48,6 +51,7 @@ public class WebViewController: UIViewController, WKNavigationDelegate, WKUIDele
48
51
}
49
52
}
50
53
54
+ /// Navigates to the local file url in embedded WKWebView-object
51
55
public func navigateToFile( url: URL ) {
52
56
webView. loadFileURL ( url, allowingReadAccessTo: url. deletingLastPathComponent ( ) )
53
57
}
@@ -179,7 +183,7 @@ extension WebViewController: WKScriptMessageHandler{
179
183
let js2 : String = " cueSDKCallback(JSON.stringify( \( paramData) )) "
180
184
print ( " Sent to Javascript: \( js2) " )
181
185
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 " )
183
187
} )
184
188
}
185
189
} else {
0 commit comments