Comment on page
Messaging
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. appDelegate.mitter.messaging.sendTextMessage(
forChannel: "rakfT-XPdJb-WsucS-Pxy4B",
"Hello from iOS!"
) { result in
switch result {
case .success:
print("Message sent!")
case .error:
print("Couldn't send message")
}
}
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.
You can get messages sent to a particular channel by calling the
getMessagesInChannel()
and passing in the channel ID:appDelegate.mitter.messaging.getMessagesInChannel("rakfT-XPdJb-WsucS-Pxy4B") {
result in
switch result {
case .success(let messages):
print("Messages: \(messages)")
case .error:
print("Couldn't fetch messages")
}
}
Run the project and you should be getting a list of messages printed to your console log.
Last modified 4yr ago