Hi
I am trying to create a flutter wrapper for Sendbird and being a complete beginner to Swift I am struggling. The function I am running is as follows:
static func extractChannel( channel: SBDBaseChannel, js: inout NSMutableDictionary
){
js["cover_url"] = channel.coverUrl
js["name"] = channel.name
js["url"] = channel.channelUrl
js["data"] = channel.data
js["is_open_channel"] = channel.isOpen()
var channelMetadata = [String: Any]()
channel.getAllMetaData{ (metaData, error) in
guard let metadata = metaData, error == nil else { // Error.
return
}
channelMetadata = metadata
}
js["status"] = channelMetadata["status"]
switch channel{
case let opench as SBDOpenChannel:
js["custom_type"] = opench.customType
case let groupch as SBDGroupChannel:
js["is_public"] = groupch.isPublic
js["custom_type"] = groupch.customType
js["unread_message_count"] = groupch.unreadMessageCount
var msg = NSMutableDictionary()
if( groupch.lastMessage != nil ) {
extractMessage( msg: groupch.lastMessage!, js: &msg )
}
js["last_message"] = msg
let members = NSMutableArray()
if( groupch.members != nil ) {
for member in (groupch.members as! [SBDMember] ){
let jsmem = NSMutableDictionary()
jsmem["nickname"] = member.nickname
jsmem["user_id"] = member.userId
jsmem["profile_url"] = member.profileUrl
members.add(jsmem)
}
}
js["members"] = members
let readlist = NSMutableDictionary()
let readInfo = groupch.getReadStatus(includingAllMembers: true)
// 'getReadStatus' Function may deprecated
for (k, info) in readInfo {
let jsinfo = info as NSDictionary
readlist[k] = jsinfo["last_seen_at"]
}
js["read_status"] = readlist
default:
NSLog("channel extract error")
}
}
`
However, when I try to retrieve the value of the “status” key it always returns null, even though I know that the key has a value.
I have searched for a solution for ages ages and tried many different approaches, but to no avail. What am I doing wrong? Any help would be much appreciated!