Cflux
Cflux

Reputation: 1532

Pusher Chatkit Android get status readout of specified room

I'm trying to integrate pusher chatkit and I'm curious of a couple of things:

1) is there a way to get a readout of the status of a specific room similar to when you join a room...or get denied from a room. Here's an example below when you join a room.

D/TAG: Message(id=102785662, sender=User(id=username1-PCKid, createdAt=2020-01-02T01:44:28Z, updatedAt=2020-01-02T01:44:28Z, name=username1, avatarURL=null, customData=null, online=true), room=Room(id=my-room2, createdById=alice, name=my room2, pushNotificationTitleOverride=null, isPrivate=false, customData=null, unreadCount=14, lastMessageAt=2020-01-15T15:34:45Z, createdAt=2020-01-01T20:48:29Z, updatedAt=2020-01-01T20:48:29Z, deletedAt=null), parts=[Part(partType=Inline, payload=Inline(type=text/plain, content=updates on click))], createdAt=Wed Jan 15 07:34:45 PST 2020, updatedAt=Wed Jan 15 07:34:45 PST 2020, deletedAt=null)

******UPDATE*** was able to solve number 1 with this being called from adapter:

    fun addRoom(room:Room){

        list.add(room);
        Log.d(AppActivityTags.chatRoomsListAdapterTAG, "Room name: " + room.name)
        Log.d(AppActivityTags.chatRoomsListAdapterTAG, "Room id: " + room.id)
        Log.d(AppActivityTags.chatRoomsListAdapterTAG, "Room memberUserIds: " + room.memberUserIds)
        Log.d(AppActivityTags.chatRoomsListAdapterTAG, "Room isPrivate: " + room.isPrivate)

    }

2) how can I get a list of a room's members? I tried room.memberUserIds but it comes back empty.

3) I am new to kotlin and also pusher chatkit, could someone please show me an example of how to log

currentUser.getJoinableRooms { result ->
  when (result) {
    is Result.Success -> {
      // Do something with List<Room>
      // show me joinable rooms
    }
  }
}

I'm guessing this will crank out nonPrivate rooms.

4) I am getting this error D/ChatRoomsActivity:  on subscripetoRoomMultipart reason:: Room membership required however, the user is already a member of the room as is shown in the pusher chatkit console. currently user id=username1-PCKid

enter image description here

Upvotes: 0

Views: 120

Answers (1)

Danielle
Danielle

Reputation: 181

1 - You can get all the rooms you're a member of with CurrentUser.rooms and most of the status information will be available as soon as you connect to Chatkit e.g. unread counts and room name. You could write a for each loop to log out the information after you connect. However...

2 - It looks like you want the current users for a given room. For this you will need to be subscribed to the room before this is populated.

3 - You are correct, that will return all the joinable rooms. You could write a for each loop to log out each joinable room.

4 - Can you provide some more info - it'd be useful to see what your code is doing and in what order!

We have a public demo app that models some of this - https://github.com/pusher/chatkit-android-public-demo

We have also got a getting started guide here that might be useful - https://pusher.com/docs/chatkit/getting_started/android

Finally, the reference docs might be another good place to checkout - https://pusher.com/docs/chatkit/reference/android

Hope that helps :-)

Upvotes: 0

Related Questions