mirror of
https://github.com/hub-team/OnlineChatSdk-SwiftPM.git
synced 2026-04-14 16:53:52 +00:00
0.2.4
This commit is contained in:
@@ -34,6 +34,11 @@ open class ChatApi {
|
||||
}
|
||||
}
|
||||
|
||||
public func setInfo(_ token: String, params: Dictionary<String, Any>, callback: @escaping (NSDictionary?) -> Void) {
|
||||
send(token, "chat/client/setInfo", params, callback: callback)
|
||||
}
|
||||
|
||||
|
||||
public func messages(_ token: String, params: Dictionary<String, Any>, callback: @escaping (NSDictionary?) -> Void) {
|
||||
send(token, "chat/message/getList", params, callback: callback)
|
||||
}
|
||||
@@ -53,4 +58,8 @@ open class ChatApi {
|
||||
] as [String : Any]
|
||||
(ChatApi()).messages(token, params: params, callback: callback)
|
||||
}
|
||||
|
||||
public static func setInfo(_ token: String, _ params: Dictionary<String, Any>, callback: @escaping (NSDictionary?) -> Void) {
|
||||
(ChatApi()).setInfo(token, params: params, callback: callback)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,6 +134,23 @@ open class ChatController: UIViewController, WKNavigationDelegate, WKScriptMessa
|
||||
callback( ChatController.getNewMessagesCallback(result!) )
|
||||
})
|
||||
}
|
||||
|
||||
public static func setInfoCustomDataValue(key: String, value: String, callback: @escaping (NSDictionary?) -> Void) {
|
||||
DispatchQueue.global().async {
|
||||
ChatApi.setInfo(
|
||||
ChatConfig.getApiToken(),
|
||||
[
|
||||
"client": [
|
||||
"id": ChatConfig.getClientId(),
|
||||
"customData": [
|
||||
key: value
|
||||
]
|
||||
],
|
||||
] as [String : Any],
|
||||
callback: callback
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override public func loadView() {
|
||||
let contentController = WKUserContentController()
|
||||
@@ -288,6 +305,7 @@ open class ChatController: UIViewController, WKNavigationDelegate, WKScriptMessa
|
||||
}
|
||||
|
||||
private func callJs(_ script: String) {
|
||||
print("callJs : \(script)")
|
||||
chatView.evaluateJavaScript(script)
|
||||
}
|
||||
|
||||
@@ -487,6 +505,7 @@ open class ChatController: UIViewController, WKNavigationDelegate, WKScriptMessa
|
||||
switch name {
|
||||
case ChatController.method_pageLoaded:
|
||||
injectCss(style: self.css)
|
||||
onChatWasOpen()
|
||||
break
|
||||
case ChatController.event_closeSupport:
|
||||
onCloseSupport()
|
||||
@@ -520,6 +539,14 @@ open class ChatController: UIViewController, WKNavigationDelegate, WKScriptMessa
|
||||
onEvent(name, data!)
|
||||
}
|
||||
|
||||
open func onChatWasOpen() {
|
||||
|
||||
}
|
||||
|
||||
open func onChatWasClosed() {
|
||||
|
||||
}
|
||||
|
||||
open func onCloseSupport() {
|
||||
if chatView == nil {
|
||||
return
|
||||
@@ -530,6 +557,8 @@ open class ChatController: UIViewController, WKNavigationDelegate, WKScriptMessa
|
||||
|
||||
dismiss(animated: true, completion: nil)
|
||||
navigationController?.popViewController(animated: true)
|
||||
|
||||
onChatWasClosed()
|
||||
}
|
||||
|
||||
open override func viewDidDisappear(_ animated: Bool) {
|
||||
|
||||
Reference in New Issue
Block a user