Custom Message

To send a custom message, you must pass in a Dictionary instance. The server will populate this as a JSON format. Later on, you must parse it by yourselves depending on the key and value that you set earlier on.

// Sending an integer
let data = ["anykey": 10]

// Sending an array
let data = ["anykey": [10, 14]]

// Sending a dictionary of an array of integer
let data = ["anykey": ["anykey": [10, 12]]]

...

let messageId = messageRepository.createCustomMessage(withChannelId: "CHANNEL_ID", 
                                                               data: data, 
                                                               tags: nil, 
                                                           parentId: nil) { message, error in
     // Handle message creation result.
}

token = messageRepository.getMessage(messageId)?.observe { liveMessage, error in
    // Observe message data changes.
}

Viewing Custom Message

A custom message will be sent as a JSON format. If you wish to show the message, remember to parse the value. You are responsible to parse your own custom type data.

Last updated