Search code examples
react-nativesendbird

sendbird error - Connection should be made first


I am using RN v0.46.4 and sendbird v3.0.35

I am trying to make a channel but getting the error:

Connection should be made first error code : 800101

_chat(item){

  console.log(item);

  var userIds = [1, item.id];
  sb = new SendBird({appId: APP_ID});
    sb.connect(item.id, function(user, error) {
          console.log(user);

        })

sb.GroupChannel.createChannelWithUserIds(userIds, true, item.firstname, function(createdChannel, error) {
    if (error) {
        console.error(error);
        return;
    }

    console.log(createdChannel);
});
}

Solution

  • You should call createChannel within connect function's callback so we can make sure that connect() has succeeded.