Live collections are not working for ts-sdk


I’m new here and I’m trying to create a simple chat app but I find myself unable to get live updates for channels and messages.

I have tried using live collections for this and I get the right data on the first call, but for instance, in the case of messages, if I send a message as a different user I don’t see the message listed in the other device unless I call again liveMessages manually.

Is this how it’s supposed to work or I’m missing something?

Are live collections working for everybody else? I’m still stuck because I can’t find a way to make my app update live as I create and send messages from different devices. I’m using Expo for my App. I’d really appreciate if somebody can help me out with this.

I can see how messages in my live channels update inside my Amity Console but websocket events seem to not get triggered inside my RN app. Has anybody else experienced something similar?

Hello @nockingTheArrow To confirm my understanding, you mentioned that you have to call liveMessages again in order to see your messages on another device, is that correct? Could you please provide me with your relevant code and current SDK version?

Yes. I found out the solution here: How to get live messages from ts-sdk - #7 by cijin

I thought the app would get subscribed to channel messages updates when calling the liveMessages method but I see now we have to do this manually.

The same is happening for me when trying to keep the channels users are members of listed. If I add or remove users from channels I don’t the list updating live so I guess there’s a topic I need to subscribe to.

Is there somewhere in the docs where I can see the topics I can subscribe to and the events they emit?

Hi @nockingTheArrow ,

This explains the usage of live objects

If any more questions or issues still persists please let us know.

Thank you,
Amity Support

1 Like

Hey @nockingTheArrow,

I’m in the process of updating the docs regarding such issues. For now I can share a detailed usage for live channels, here.

import { ChannelRepository, subscribeTopic, getChannelTopic } from '@amityco/ts-sdk';
import { FC, useEffect, useState } from 'react';

const disposers: Amity.Unsubscriber[] = [];
const subscribedChannels: Amity.Channel['channelId'][] = [];

const subscribeChannels = (channels: Amity.Channel[]) =>
  channels.forEach(c => {
    if (!subscribedChannels.includes(c.channelId) && !c.isDeleted) {


const GetChannels: FC = () => {
  const [channels, setChannels] = useState<Amity.Channel[]>();

  useEffect(() => {
     * Possible params for liveChannels
     * displayName?: string;
     * membership?: 'all' | 'member' | 'notMember';
     * sortBy?: 'displayName' | 'firstCreated' | 'lastCreated';
     * types?: ['live', 'conversation', 'community', 'broadcast'];
     * isDeleted?: boolean;
     * tags?: ['tag1', 'tag2']
     * excludeTags?: ['tag3', 'tag4']
     * limit?: number
     * }
    const unsubscribe = ChannelRepository.getChannels(
      ({ data: channels, onNextPage, hasNextPage, loading, error }) => {
         * this is only required if you want real time updates for each
         * channel in the collection

     * if you only wish to get a collection or list of paginated channel without
     * any real time updates you can unsubscribe immediately after you call the
     * collection.
     * ex: unsubscribe()

    return () => {
      disposers.forEach(fn => fn());

  return null;

Please reach out if you have further questions.
1 Like

Thanks @cijin.

This is the approach I ended up following for chats and it’s working. I was wondering what topic should I subscribe users to if I want them to receive updates when they’re added to new chats. Currently this works for keeping the chat list they get on their first query updated but I don’t think they’ll have new chats pop up in their list as they’re added.

Edit: I want to know if there’s a topic I can subscribe to in order to have users’ list of live channels updated whenever they get added or removed from any.

Hey @nockingTheArrow,

  1. If I understand correctly, do you mean newly created messages don’t appear in the channel as they are created? If yes, I’ll look into this.

  2. To get a users list of live channels you could use the membership param { membership: 'member' }

Hope, that answers part of your question. I’ll try to answer asap after I understand the first part clearly. Thank you being patient :slight_smile:

1 Like

Thanks @cijin for your answers.

  1. This was the first problem I was trying to solve, I solved it by subscribing to the subchannel topic as you pointed out in a different thread and then I started getting them as they were created. Currently it seems like there are some issues with subscriptions because I can’t subscribe to any topic, not even the topics it automatically subscribes to when you login users to Amity.

  2. I get that and it’s what I’m currently doing and it works fine for the first query, but then, as I’m using channels of type “Live”, I don’t get any update on the list when adding or removing users from them. I wonder if I can do this without having to subscribe to each channel retrieved in the list one by one.

Thanks for your time.


Hey :slight_smile:,

  1. Looks like server is denying the subscriptions. Is the session established? Are you able to call the other async API’s?

  2. Unfortunately, as it is. live and broadcast type channels require subscribing the the channels individually.

1 Like

Hi @nockingTheArrow

We’ll proceed to closing this issue now assuming resolution. In case there’s anything else please don’t hesitate to let us know.

Thank you,
Amity Support

1 Like