Search code examples
iosobjective-ctwiliotwilio-apitwilio-conversations

How to get participants for a conversation in Twilio


I'm using the Twilio Conversations Client for iOS. How do you get the participants for a conversation? Each conversation object has a participants array object.

[TwilioConversationsClient conversationsClientWithToken:token properties:nil delegate:self
    completion:^(TCHResult *result, TwilioConversationsClient *convoClient) {   

    NSArray *participants = self.client.myConversations.firstObject.participants;

}];

How do you reload this array? I don't see any method like "getParticipants" to reload these values.

For instance, to reload the messages for a conversation there is this method.

- (void)getMessagesAfter:(NSUInteger)index
               withCount:(NSUInteger)count
              completion:(nonnull TCHMessagesCompletion)completion;

Solution

  • Twilio developer evangelist here.

    That is odd that there isn't a method to reload the participants array. It exists within the JavaScript SDK, so I would have thought it would exist in the iOS SDK, but it doesn't for now.

    So, the participants call you refer to is the way to get the initial list of participants after loading the conversation, then you should keep up with the participants that have joined and left the conversation using the participantJoined and participantLeft delegate methods.