We have provided the following diagnostics tips to help capture issues while using Twilio Conversations iOS SDK. These tips are also valuable in providing logs and details to Twilio Support.
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 registering for notifications failed, errorReceived
can be used.
func conversationsClient(_ client: TwilioConversationsClient, errorReceived error: TCHError)..
This method will be called during client creation if any error occurs. 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:
connectionStateUpdated
events are emitted for the various connection states through the ConversationsClientDelegate:
The connection states are a constant:
Possible values are as follows:
connecting
- client is offline and connection attempt is in processconnected
- client is online and readydisconnecting
- client is going offline as disconnection is in processdisconnected
- client is offline and no connection attempt is in processdenied
- client connection is denied because of invalid JWT access token. User must refresh token in order to proceed
disconnecting
is a graceful disconnect meaning the SDK already knows that this is going to happen. On the other-hand, 'disconnected' means the client is simply offline and there is no connection in place, hence there is no attempt to connect. The disconnecting
state can happen because of errors such as the client being not able to establish connection with the server due to various reasons such as Internet issues, a disconnection would happen as a result.