chat-sdk / chat-sdk-ios

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

get role for user in a group and change role #498

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? get

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

  4. Steps taken to reproduce the problem:-(nonnull NSString ) role: (nonnull NSString ) threadEntityID forUser: (nonnull NSString *) userEntityID; function used

  5. Expected result: get roles for user in the thread

  6. Actual result: empty

  7. Comments: How to get roles for user in a group and also how to setrole for members in a thread

bensmiley commented 2 years ago

You can set a role like this:

let userId = "user id"
let threadId = "thread id"
if BChatSDK.thread().canChangeRole(threadId, forUser: userId) {
    BChatSDK.thread().setRole(Affiliation.admin, forThread: threadId, forUser: userId).thenOnMain({ success in

    }, { error in

    })
}

You can get a role like this:

let userId = "user id"
let threadId = "thread id"

let role = BChatSDK.thread().role(threadId, forUser: userId)

If the role is nil, then it could be for a number of reasons:

  1. Roles not supported by thread type
  2. User banned
  3. User not a member

etc...