I am developing a 1:1 chat application. I use a PHP server to create the private channel before starting the application. The channels are created correctly.
The user tokens are genereated, chat client also created correctly. I see that the user is also created in the service.
When joining the private channel, it throws the error.
code:50400 message:"User not member of channel" status:403
Javascript code:
Twilio.Chat.Client.create(token,clientOptions).then(client => {
chatClient = client;
showMessage('Connecting.....');
chatClient.getChannelBySid(channelid)
.then(function(chosenChannel) {
showMessage('Joining Chat.....');
myChannel=chosenChannel;
joinChannel();
})
.catch(function(err) {
console.log(err);
})
});
It shows the message 'Connecting....' and then stops with the error.
PHP Code:
$client = new Client("sid", "token");
$channel = $client->chat->services("serviceid")->channels
->create(array('friendlyName' => $friendlyName, 'uniqueName' => $uniqueName, 'type' => 'private'));