SyncManager onChannelChanged not triggered when changing custom type

The onChannelChanged not triggered at all when changing custom type even though from the doc said supported https://docs.sendbird.com/android/sync_manager_channel_sync

onChannelChanged - One of the following group channel properties has been changed: distinct, push notification preferences, last message (excluding silent admin messages), unread message count, name, cover image, data, or custom type. If the collection doesn’t have the channel in the channel list, an insert event is given instead of update . If the property change affects the order of the channel list, the move event is also invoked.

Is this a bug from the Android SDK?

hi, @wisnup

How did you try to update custom type?! I checked ChannelEventAction.UPDATE is called when channel custom type is updated.

You can update channel custom type like below.

GroupChannelParams params = new GroupChannelParams().setCustomType("your type");
channel.updateChannel(params, new GroupChannel.GroupChannelUpdateHandler() {
@Override
 public void onResult(GroupChannel groupChannel, SendBirdException e) {
       if (e != null) {
             Logger.d("error");
        }
        Logger.d("updated custom type");
     }
 });

The update comes from back-end. Below’s the code. Also we can update the custom type directly from Sendbird Dashboard.

 public static updateChannel(
    channel: SendBird.GroupChannel,
    feedbackData?: FeedbackData,
  ): Promise<SendBird.GroupChannel> {
    return new Promise((resolve, reject) => {
      const parsedData = this.safelyParseJSON(channel.data);
      const newData = !!feedbackData
        ? JSON.stringify({ ...parsedData, ...feedbackData })
        : channel.data;
      channel.updateChannel(
        false,
        channel.name,
        channel.coverUrl,
        newData,
        'NEW_CUSTOM_TYPE',
        (response, error) => {
          if (error) {
            reject(error);
          }

          resolve(response);
        },
      );
    });
  }

Did you check your log?!

I have successfully received the update event.
You have to define your ChannelCollectionHandler and set it on your collection.
You can get UPDATE event from ChannelCollectionHandler.

GroupChannelListQuery query = GroupChannel.createMyGroupChannelListQuery();
query.setLimit(CHANNEL_LIST_LIMIT);
mChannelCollection = new ChannelCollection(query);
mChannelCollection.setCollectionHandler(mChannelCollectionHandler);

Yeah we checked our log. The query code is similar to yours but we also add custom type filter.

mChannelCllection.query.customTypesFilter = customTypes

Is it works with the filter? If we change the custom type from it (the one set as filter) to another custom type and vice versa?

Ah I think the exact problem is like this:

  1. Create a channel collection with custom type filter ‘A’
  2. Change a channel custom type from ‘A’ to ‘B’. Event is not triggered.
  3. But if we change from ‘B’ to ‘A’ the event is triggered.

Is this a feature or bug?

This is a feature. We collect channels based on query. If you set the custom type filter, query can get channels only filtered by customers. If you want to hide a channel, you can use hide method.

1 Like

Okay then, understood. Thanks for replying @Doo_Rim :smiley: :+1:

1 Like