# Can't get Metadata

**URL:** <https://community.sendbird.com/t/cant-get-metadata/836>\
**Category:** iOS\
**Tags:** group-channel, metadata-key\
**Created:** [August 24, 2020, 12:53pm UTC](https://community.sendbird.com/t/cant-get-metadata/836 "2020-08-24T12:53:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicholas\_Latham](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/nicholas_latham/32/369_2.png) [@Nicholas\_Latham](https://community.sendbird.com/u/Nicholas_Latham)\
**Post date:** [August 24, 2020, 12:53pm UTC](https://community.sendbird.com/t/cant-get-metadata/836/1 "2020-08-24T12:53:19Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Alex\_Preston](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/alex_preston/32/167_2.png) [@Alex\_Preston](https://community.sendbird.com/u/Alex_Preston)\
**Post date:** [August 25, 2020, 10:28pm UTC](https://community.sendbird.com/t/cant-get-metadata/836/2 "2020-08-25T22:28:18Z")

</div>

Hey @Nicholas_Latham are you saying the “status” key is null on channelMetaData? Do you mind telling me what SDK you are working off of?

---

<div class="post-metadata">

**Author:** ![Nicholas\_Latham](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/nicholas_latham/32/369_2.png) [@Nicholas\_Latham](https://community.sendbird.com/u/Nicholas_Latham)\
**Post date:** [August 26, 2020, 7:53am UTC](https://community.sendbird.com/t/cant-get-metadata/836/3 "2020-08-26T07:53:03Z")

</div>

Hi Alex, I am working with the Sendbird-iOS SDK. I am forking an existing “flutter wrapper” project for Sendbird which seems to do most of what I want:

> **[sensestar/flutter\_sendbird](https://github.com/sensestar/flutter_sendbird)**
>
> Contribute to sensestar/flutter\_sendbird development by creating an account on GitHub.

however it doesn’t extract Channel Metadata.

My hunch is that because getAllMetaData is `async` the call doesn’t complete before I do ` js["status"] = channelMetadata["status"]` so `channelMetadata["status"]` is empty. As I said I am a complete beginner with Swift and despite trying many things (e.g. `DispatchGroup()`) it always returns null

---

<div class="post-metadata">

**Author:** ![Alex\_Preston](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/alex_preston/32/167_2.png) [@Alex\_Preston](https://community.sendbird.com/u/Alex_Preston)\
**Post date:** [August 26, 2020, 11:39pm UTC](https://community.sendbird.com/t/cant-get-metadata/836/4 "2020-08-26T23:39:56Z")

</div>

@Nicholas_Latham, I meant what SDK version sorry. But that isn’t needed. Ahh yea you are right. So there is a chance that the callback from `getAllMetaData` hasn’t returned yet. In fact, I would assume based on the call:

`js["status"] = channelMetadata["status"]`

and its place meant outside the callback, that the value of `channelMetadata['status']` would be null. I think you should wait for the assignment until you get the response of the `getAllMetaData` call.
