The Twilio Conversations SDK for iOS allows users to collect debugging logs for any errors they may be seeing. This guide provides helpful diagnostics tips and code samples for capturing logs of any issues you run into.
TCHResult
Most operations that can be performed on objects in Conversations for iOS return a TCHResult object to their completion block. This includes operations against Conversations, Messages, and Participants.
This object contains an isSuccessful
method, as well as an error
property, which will be populated with an error, should the operation fail. Your application should check for this error and never disregard it.
For more details, see our iOS Error Handling - Objective-C, Swift documentation.
conversation.SomeEvent(message) { tchResult in
if let error = tchResult.error {
self.delegate?.onSomeEventError(error)
return
errorReceived
For issues where the client could not be initialised, the token update failed, or notification registration failed, errorReceived
can be used.
func conversationsClient(_ client: TwilioConversationsClient, errorReceived error: TCHError)..
This method will be called during client creation if any errors occur. If client initialization fails, and a nil
client is returned, this method will be called with an explanation of why the creation failed.
Connection events:
The connectionStateUpdated
events are emitted for various connection states through the ConversationsClientDelegate. The connection states are a constant.
Here are the possible values:
connecting |
client is offline and a connection attempt is in process |
connected |
client is online and ready |
disconnecting |
client is going offline and a disconnection is in process |
disconnected |
client is offline and no connection attempt is in process |
denied |
client connection is denied because of invalid JWT access token. User must refresh token in order to proceed |
Notice: The disconnecting
state indicates a graceful disconnect, and that the SDK already knows that this is going to happen. However, it can also be caused by errors, such as the client being not able to establish connection with the server for various reasons.