mirror of
https://github.com/hub-team/OnlineChatSdk-SwiftPM.git
synced 2026-04-15 17:06:09 +00:00
0.2.7
This commit is contained in:
@@ -39,6 +39,8 @@ open class ChatController: UIViewController, WKNavigationDelegate, WKScriptMessa
|
|||||||
private var widgetOrg: String = ""
|
private var widgetOrg: String = ""
|
||||||
private var css: String = ""
|
private var css: String = ""
|
||||||
private var alertLoading: UIAlertController?
|
private var alertLoading: UIAlertController?
|
||||||
|
private let logTag = "OnlineChatSdk"
|
||||||
|
private var isOnCloseSupport = false
|
||||||
|
|
||||||
private static func getUnreadedMessagesCallback(_ result: NSDictionary) -> NSDictionary {
|
private static func getUnreadedMessagesCallback(_ result: NSDictionary) -> NSDictionary {
|
||||||
let resultWrapper = ChatApiMessagesWrapper(result)
|
let resultWrapper = ChatApiMessagesWrapper(result)
|
||||||
@@ -307,7 +309,7 @@ open class ChatController: UIViewController, WKNavigationDelegate, WKScriptMessa
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func callJs(_ script: String) {
|
private func callJs(_ script: String) {
|
||||||
print("callJs : \(script)")
|
print("\(logTag) :: callJs :: \(script)")
|
||||||
chatView.evaluateJavaScript(script)
|
chatView.evaluateJavaScript(script)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,13 +386,14 @@ open class ChatController: UIViewController, WKNavigationDelegate, WKScriptMessa
|
|||||||
}
|
}
|
||||||
self.css = css
|
self.css = css
|
||||||
var encodeDomain: String = String(describing: domain.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed))
|
var encodeDomain: String = String(describing: domain.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed))
|
||||||
if (encodeDomain.contains("Optional(\"")) {
|
if encodeDomain.contains("Optional(\"") {
|
||||||
encodeDomain = encodeDomain.replacingOccurrences(of: "Optional(\"", with: "")
|
encodeDomain = encodeDomain.replacingOccurrences(of: "Optional(\"", with: "")
|
||||||
encodeDomain = encodeDomain.replacingOccurrences(of: "\")", with: "")
|
encodeDomain = encodeDomain.replacingOccurrences(of: "\")", with: "")
|
||||||
}
|
}
|
||||||
widgetUrl = "https://admin.verbox.ru/support/chat/\(id)/\(encodeDomain)"
|
widgetUrl = "https://admin.verbox.ru/support/chat/\(id)/\(encodeDomain)"
|
||||||
widgetOrg = "https://admin.verbox.ru/support/chat/\(id)/"
|
widgetOrg = "https://admin.verbox.ru/support/chat/\(id)/"
|
||||||
var url = URL(string: widgetUrl)
|
var url = URL(string: widgetUrl)
|
||||||
|
if url != nil {
|
||||||
var urlComponents = URLComponents(url: url!, resolvingAgainstBaseURL: false)
|
var urlComponents = URLComponents(url: url!, resolvingAgainstBaseURL: false)
|
||||||
if !setup.isEmpty {
|
if !setup.isEmpty {
|
||||||
if (showCloseButton) {
|
if (showCloseButton) {
|
||||||
@@ -410,10 +413,17 @@ open class ChatController: UIViewController, WKNavigationDelegate, WKScriptMessa
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
url = urlComponents!.url!
|
url = urlComponents!.url
|
||||||
|
}
|
||||||
if url == nil {
|
if url == nil {
|
||||||
url = URL(string: widgetUrl)
|
url = URL(string: widgetUrl)
|
||||||
}
|
}
|
||||||
|
if url == nil {
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
|
||||||
|
self.showMessage("url=\(self.widgetUrl) not init")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
chatView.load(URLRequest(url: url!))
|
chatView.load(URLRequest(url: url!))
|
||||||
chatView.allowsBackForwardNavigationGestures = true
|
chatView.allowsBackForwardNavigationGestures = true
|
||||||
}
|
}
|
||||||
@@ -478,6 +488,7 @@ open class ChatController: UIViewController, WKNavigationDelegate, WKScriptMessa
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func callJsDestroy() {
|
private func callJsDestroy() {
|
||||||
|
print("\(logTag) :: callJsDestroy")
|
||||||
callJsMethod(ChatController.method_destroy, params: [])
|
callJsMethod(ChatController.method_destroy, params: [])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,6 +550,7 @@ open class ChatController: UIViewController, WKNavigationDelegate, WKScriptMessa
|
|||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
print("\(logTag) :: userContentController :: \(data!)")
|
||||||
onEvent(name, data!)
|
onEvent(name, data!)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -575,9 +587,15 @@ open class ChatController: UIViewController, WKNavigationDelegate, WKScriptMessa
|
|||||||
}
|
}
|
||||||
|
|
||||||
open func onCloseSupport() {
|
open func onCloseSupport() {
|
||||||
|
if (isOnCloseSupport) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
isOnCloseSupport = true
|
||||||
|
print("\(logTag) :: onCloseSupport :: 1")
|
||||||
if chatView == nil {
|
if chatView == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
print("\(logTag) :: onCloseSupport :: 2")
|
||||||
chatView.stopLoading()
|
chatView.stopLoading()
|
||||||
callJsDestroy()
|
callJsDestroy()
|
||||||
chatView = nil
|
chatView = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user