Custom Data

LAST EDIT Jul 21 2021

Changing the default extra data types with your custom types is easy and takes a couple of easy steps.

For example, let's say you want to replace the default NoExtraData of ChatChannel with your custom NameAndColorExtraData:

1. Define your custom Channel extra data type

Copied!

Your custom data type must conform to the ChannelExtraData protocol. The protocol has two requirements: the type must be codable, and it must expose a static defaultValue variable.

2. Use the type in your custom implementation of ExtraDataTypes

Copied!

3. Define the following typealiases in your module

Copied!

You should define the convenience typealiases in the module where you use StreamChat. You can copy&paste the snippet below, and replace MyCustomExtraData with the type defined in step 2.

Important

Copied!

Extra data is embedded directly to the root object, not nested under any extraData object.

So if you have such a Channel object: