Swift

Sending a message

In the previous step you learned about conversations and events, sending a message creates a new event and sends it via the conversation.

To send a message, add the following function to ChatViewController.swift:

To get the text from the inputField you need to add another function provided by the UITextFieldDelegate. Add the following function to the UITextFieldDelegate extension:

This delegate function is called when the return button on the keyboard is pressed.

Build and Run

Cmd + R to build and run again. You now have a functioning chat app! To chat simultaneously you can run the app on two different simulators/devices:

Sent messages