Live Chat SDK Swift
Last updated
Was this helpful?
Was this helpful?
import imi_dolphin_livechat_ioslet dolphinProfile = DolphinProfile(
name: nameTextField.text!,
email: emailTextField.text!,
phoneNumber: phoneTextField.text!,
customerId: "",
uid: ""
)var connector: Connector?
let notificationMessage = "com.connector.notificationMessage"
let notificationConnectionStatus = "com.connector.connectionStatus"
let notificationReadMessage = "com.connector.notificationReadMessage"
let notificationTypingCondition = "com.connector.notificationTypingCondition"connector!.setupConnection(baseUrl: baseUrl, clientId: clientId, clientSecrect: clientSecrect)
connector?.enableGetQueue(isEnable: false)
connector!.constructConnector(profile: dolphinProfile!)
NotificationCenter.default.addObserver(self, selector: #selector(doOnReceiveMessage(_:)), name: Notification.Name(rawValue: notificationMessage), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(doUpdateConnectionStatus(_:)), name: Notification.Name(rawValue: notificationConnectionStatus), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(doUpdateStatusMessage(_:)), name: Notification.Name(rawValue: notificationReadMessage), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(doUpdateTypingCondition(_:)), name: Notification.Name(rawValue: notificationTypingCondition), object: nil)
@objc func doOnReceiveMessage(_ notification: NSNotification) {
let newMessage = notification.object as! DolphinMessage
// Handle received message
}
@objc func doUpdateConnectionStatus(_ notification: NSNotification) {
let status: Int = notification.object as! Int
// Handle connection status updates
}
@objc func doUpdateStatusMessage(_ notification: NSNotification){
let updatedMessage = notification.object as! DolphinMessage
// Handle message status updates
}
@objc func doUpdateTypingCondition(_ notification: NSNotification){
// Handle typing condition updates
}connector?.onSendMessage(messages: "TEXT_MESSAGE_STRING", dataUser: sample)connector!.sendAttachment(fileNsUrl: "IMAGE_FILEPATH", state: state!, dataUser: sample)connector!.sendAttachment(fileNsUrl: "VIDEO_FILEPATH", state: state!, dataUser: sample)connector?.sendAttachment(fileNsUrl: AUDIO/DOCUMENT_FILEPATH as NSURL, state: state!, dataUser: sampl