chat-sdk / chat-sdk-ios

Chat SDK iOS - Open Source Mobile Messenger
http://sdk.chat
Other
913 stars 276 forks source link

could not join a group #500

Closed vineethsreekumar closed 2 years ago

vineethsreekumar commented 2 years ago
  1. Is the bug present in the demo Chat SDK project? - yes

  2. What modifications have you made to the Chat SDK? - a user could not join a group thread

  3. iOS Version? Device or simulator? iphone 13 pro max

  4. Steps taken to reproduce the problem: let grouptthread = BChatSDK.db().thread(forEntityID: "-N0adpBTTN_xMSYNL2f0") use join function in chatSDK.thread().join(groupthread)

  5. Expected result: the current user should be joined to the group thread

  6. Actual result: groupthread is nil

  7. Comments: Can we add a user to a group thread in this way or do you have any other way to join a pivate group @bensmiley @denniszxxc @angelolloqui @ealeksandrov

bensmiley commented 2 years ago

The correct code would be something like this:

if let thread = BChatSDK.db().fetchOrCreateEntity(withID: "thread-id", withType: bThreadType) as? PThread {
    if(BChatSDK.thread().canJoin(thread)) {
        BChatSDK.thread().join(thread)
    }
}

But there is no guarantee the user can join. In general, users need to be invited by the thread owner.

vineethsreekumar commented 2 years ago

How a thread owner can invite another user?

vineethsreekumar commented 2 years ago

How a thread owner can invite another user?

@bensmiley

vineethsreekumar commented 2 years ago

@bensmiley we already tried fetchOrCreateEntity the thread doesnt have any meta and other data. seems we need to do invite from creator side. How we can invite a user with chatSDK ?

abhi-9605 commented 2 years ago

How we can invite a user with chat SDK android? ( Using firebase real-time database ) @bensmiley

bensmiley commented 2 years ago

You can add users like this:

iOS:

BChatSDK.thread().addUsers([user1, user2], to: thread)

Android:

ChatSDK.thread().addUsersToThread(thread, user1, user2).subscribe()
vineethsreekumar commented 2 years ago

@bensmiley BChatSDK.thread().addUsers this will add the user right. what we need is invite a user via link and clicking on the link user should be able to join the group

bensmiley commented 2 years ago

@vineethsreekumar there is no built in function to do what you want. If you want that functionality you would need to build it yourself.