Manos Chorianopoulos

fix WebviewVC (add webviewDidFocusRefresh script)

......@@ -30,6 +30,7 @@ var timer2: DispatchSourceTimer?
var listenersCount = 0;
var webViewLoaded: Bool = false
var mWebviewSupermarket: Bool = false
public override func loadView() {
super.loadView();
......@@ -95,6 +96,10 @@ var timer2: DispatchSourceTimer?
sendWebviewDidFocus()
}
if(mWebviewSupermarket) {
sendWebviewDidFocusRefresh()
}
}
public override func viewWillDisappear(_ animated: Bool) {
......@@ -142,6 +147,7 @@ var timer2: DispatchSourceTimer?
// Handle code when the application is about to enter the foreground
sendWebviewDidFocus()
sendWebviewDidFocusRefresh()
}
@objc func applicationDidEnterBackground() {
......@@ -162,6 +168,18 @@ var timer2: DispatchSourceTimer?
})
}
func sendWebviewDidFocusRefresh() {
let scriptSource2 = "webviewDidFocusRefresh(\(self.webviewDidFocusRefresh));"
webView.evaluateJavaScript(scriptSource2, completionHandler: { (object, error) in
self.mWebviewSupermarket = false
// print("==== webviewDidFocus object ====")
// print(object)
// print("==== webviewDidFocus error ====")
// print(error)
})
}
func addApplicationObservers() {
NotificationCenter.default.addObserver(self, selector: #selector(applicationWillEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(applicationDidEnterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
......@@ -493,7 +511,7 @@ var timer2: DispatchSourceTimer?
if (eventArray[0] == "event") {
if (eventArray[1] == "closeArtwork") {
self.mWebviewSupermarket = false
self.navigationController?.popViewController(animated: true)
} else if (eventArray[1] == "addUserTag") {
......@@ -842,6 +860,9 @@ var timer2: DispatchSourceTimer?
}
}
} else if (eventArray[1] == "webviewRefresh") {
self.mWebviewSupermarket = true
}
}
......