twilio / twilio-chat-demo-android

Chat API Demo Application for Android
MIT License
62 stars 51 forks source link

Create Channel is missing the UniqueName value #148

Closed tigerfarm closed 4 years ago

tigerfarm commented 4 years ago

Description

After creating a new channel, I used a PHP program to list the channels. The UniqueName property was nil. This causes an issue in that users of my chat web application cannot exchange messages with this Android app because the web application expects a non-nill UniqueName. And, after briefing the code, it looks like you had intended to have the friendly and unique names the same.

Steps to Reproduce

  1. Run this project's chat app.
  2. Create a new channel. In the following listing, I had created channels, "abc" and "c6".
  3. Use an independent program to list the channels. Following is my sample list. Below is the code used to list the channels.
    $ php chatChannels.php 
    + CHAT_SERVICE_SID: ISd5c080247aaa4200a730da6c6ea08990:
    ++ Channel, SID: CH2310b08d51da40208ce419c1d9c013b2, unique_name: , friendlyName: abc
    ++ Channel, SID: CH2d2a23c9adf444278f924398bef71165, unique_name: , friendlyName: c6

    Code (optional)

// Code that help reproduce the issue
<?php
require __DIR__ . '/../../twilio-php-master/Twilio/autoload.php';
use Twilio\Rest\Client;
$twilio = new Client(getenv('ACCOUNT_SID'), getenv('AUTH_TOKEN'));
$CHAT_SERVICE_SID = getenv('CHAT_SERVICE_SID');
echo '+ CHAT_SERVICE_SID: ' . $CHAT_SERVICE_SID . ":\xA";
$channels = $twilio->chat->v2->services($CHAT_SERVICE_SID)
                            ->channels
                            ->read(array(), 20);
foreach ($channels as $channel) {
    echo "++ Channel"
     . ", SID: " . $channel->sid
     . ", unique_name: " . $channel->uniqueName
     . ", friendlyName: " . $channel->friendlyName
     . "\xA";
}
echo "+ End of list.\xA";

Expected Behavior

That channels are created with the uniqueName the same as the friendlyName which is the field value from the app's form.

Actual Behavior

That channels are created with the uniqueName as nil (null), the friendlyName has the correct field value from the app's form.

Reproduces how Often

Happens 100%.

Versions

All relevant version information for issue.

        applicationId "com.twilio.chat.demo"
        versionCode 26
        versionName "1.0"

Android API is recent.

Android Device

Moto G Fast, Android 10.

tigerfarm commented 4 years ago

I made the change below, and now, when I join a channel that has a uniqueName, I can chat with users that are using my chat website application. My chat website application gives the channel a uniqueName value, the uniqueName is not nil.

...
builder?.withFriendlyName("${typ}_TestChannelF_${value}")
                // ?.withUniqueName("${typ}_TestChannelU_${value}")
                ?.withUniqueName("${typ}_TestChannelF_${value}")
               ?.withType(type)
               ...
...

However, the Android Chat app still creates channels with the uniqueName as nil.

rusmonster commented 4 years ago

Hello @tigerfarm In the demo app we have two different menu items (see screenshot below):

  1. Create public channel - which shows dialog and creates a channel with friendlyName entered by user and empty uniqueName
  2. Create Pub Ch with options - which doesn't show any dialogs, just creates a channel with random friendlyName and random non-emptyuniqueName like: Pub_TestChannelU_18

I've just double checked and both options works for me without any code modifications. If it still doesn't work for you - please attach detailed log. How to collect logs

Screenshot_1601378657

berkus commented 4 years ago

No response, closing.