mitter.io
Search…
Messaging

Send a plain Text Message

Sending a plain text message is really simple. Just call the sendTextMessage() function on the Mitter.Messaging instance and pass a channel ID and text payload.
1
appDelegate.mitter.messaging.sendTextMessage(
2
forChannel: "rakfT-XPdJb-WsucS-Pxy4B",
3
"Hello from iOS!"
4
) { result in
5
switch result {
6
case .success:
7
print("Message sent!")
8
case .error:
9
print("Couldn't send message")
10
}
11
}
Copied!
Here you can specify the channel ID that you got while creating a new channel in the previous step.
Run the project and it should send out a new message to the channel.

Get messages in a channel

You can get messages sent to a particular channel by calling the getMessagesInChannel() and passing in the channel ID:
1
appDelegate.mitter.messaging.getMessagesInChannel("rakfT-XPdJb-WsucS-Pxy4B") {
2
result in
3
switch result {
4
case .success(let messages):
5
print("Messages: \(messages)")
6
case .error:
7
print("Couldn't fetch messages")
8
}
9
}
Copied!
Run the project and you should be getting a list of messages printed to your console log.
Last modified 2yr ago