start()
Note: This API is supported from version 10.0.0.
This start() API enables initiating a new call or connecting to an existing conversation using a custom conversation ID. If the provided ID corresponds to an ongoing conversation, the call will automatically be connected to it. If no such conversation exists, a new one will be created and the call will be initiated.
Parameters:
- id (String?) (Optional): The unique ID of the chat to call.
- displayActiveCall (Boolean): Determines whether to open the call screen if there is an ongoing call.
- attributes ([SalesIQConversationAttribute]?) (Optional): Attributes to customize the call, including the user's name, additional info, or display picture metadata.
- completion (ZSIQCallCompletion?): A closure that provides a success flag and an error once the call initiation is complete, as mentioned below.
- Success: The SalesIQConversation object will be provided.
- Failure: The SIQError will contain the failure details.
Note: Pass null if you do not require result handling.
Example
Copied// Define departments for the call
let departments: [SIQDepartment] = [
SIQDepartment(id: "987654321", name: "payment", mode: .call),
SIQDepartment(id: "987654320", name: "delivery", mode: .call)
] // You can provide either `id` or `name` (or both) when creating an SIQDepartment.
// Create conversation attributes
let attributes: [SalesIQConversationAttributes] = [
.name("John"),
.departments(departments),
.additionalInfo("Priority customer"),
.displayImage(UIImage(named: "profile_pic"))
]
ZohoSalesIQCalls.start(id: "12345", attributes: attributes, displayActiveCall: true) { error, conversation in
if let conversation = conversation {
// Call successfully initiated
if let chatConversation = conversation as? SalesIQChat {
// Handle the chat conversation
} else if let callConversation = conversation as? SalesIQCall {
// Handle the call conversation
}
} else if let error = error {
// Call initiation failed, handle error
print("Error starting call - Code: \(error.code), Message: \(error.message)")
}
}