Swift
Building the user model
To have a conversation you need to store some information about a user:
- A user's name
- A user's JWT
- Who they are chatting with
- The conversation ID
To do this you will use a Struct. Open ViewController.swift and add it, replacing CONVERSATION_ID with the conversation ID created earlier:
class ViewController: UIViewController {
...
}
struct User {
let name: String
let jwt: String
let chatPartnerName: String
let conversationId = "CONVERSATION_ID"
}
To make things easier for later on add some static properties on the User type for the users Alice and Bob. Replacing ALICE_JWT and BOB_JWT with the values you created earlier:
struct User {
...
static let Alice = User(name: "Alice",
jwt:"ALICE_JWT",
chatPartnerName: "Bob")
static let Bob = User(name: "Bob",
jwt:"BOB_JWT",
chatPartnerName: "Alice")
}
Creating an iOS chat app
Create a iOS application that enables users to message each other
Steps
1
Introduction to this task2
Prerequisites3
Create a Vonage Application4
Create a conversation5
Create the users6
Add users to the conversation7
Generate JWTs8
Xcode project and workspace9
Building the log in interface10
Building the user model11
NXMClient12
Building the chat interface13
Chat events14
Sending a message15
What's next?