I am trying to create a one on one channel connection, however I am not able to figure out the format for creating an SDBUser. I am doing the following to try and create the channel.
SBDGroupChannel.createChannelWithUsers([("123456", "1234567"], isDistinct: true) { (channel, error) in
if error != nil {
NSLog("Error: %@", error!)
return
} else {
//this means that the channel was successfully created
print(channel)
//segue to the open chat view
//segue here DREW
}
}
Those Strings are the ID's as they appear in SendBird. There is an error that it expected type of SDBUser, and got String.
I have tried the following to get a SBDUser, but am getting the following value
let user1 = SBDUserListQuery.init(userIds: ["123456"])
but the user value is type SBDUserListQuery, so it still does not work.
I have not been able to find a solution in the SendBird docs
SendBird has various methods to create a group channel with user objects or user IDs. The method that you used is to create a channel with user objects. The following link is the another method with user IDs.
The link is for Objective-C, but you could assume the same method in Swift like this:
Swift 3:
SBDGroupChannel.createChannel(withUserIds: ["123456", "1234567"], isDistinct: true) { (channel, error) in
// Do something.
}
And the SBDUserListQuery
object is a query object to get a user list. If you want to get a user object from the query object, you have to call a load method.
The completionHandler
block of the method returns the user list.
Swift 3:
let query = SBDUserListQuery(userIds: ["123456"]);
query?.loadNextPage(completionHandler: { (users, error) in
})