Chat availability checking
The availability of the chat can be checked any time, without starting a chat session.
BCAccount has a non-periodic asynchronous service for that. The check is implemented by the following code:
id<BCCancelable> cancelable = [account getChatAvailabilityWithDelegate:<delegate object> visitorId:@"<visitor id>"];
The visitorId parameter is optional. It is for user identification on the server side, to be able to ban out certain users. This feature is detailed in [Creating Chat Session]. The service has the following callbacks:
- (void)bcChatAvailabilityChatAvailable:(id<BCCancelable>)cancelable {
//The chat is available
}
- (void)bcChatAvailability:(id<BCCancelable>)cancelable chatUnavailableForReason:(BCUnavailableReason)reason {
//The chat is not available
// The reason is given in BCUnavailableReason enumeration.
}
- (void)bcChatAvailability:(id<BCCancelable>)cancelable didFailWithError:(NSError *)error {
//Failed to check
//Check error.code to values from BCErrorCodes.h to find out the cause of the error.
}
The chat unavailable reasons:
- BCUnavailableReasonUnknown : Reason unknown
- BCUnavailableReasonQueueFull: The number of chats waiting and in progress exceeds the queue size limit
- BCUnavailableReasonNoOperators: No agents are logged in as available
- BCUnavailableReasonVisitorBlocked: The customer has been blocked by an agent
- BCUnavailableReasonOutsideHours: It is currently outside the operating hours for the given WebsiteID
- BCUnavailableReasonUnsecure : Chat requires validation and has not been validated
Since it is an asynchronous service, this can be canceled through the cancellable returned by the request. It is true for all following requests that return cancellable.
[cancelable cancel];
The result of chat availability is cached for 1 minute.