Enable messaging
- Get recent chat list:
PTChatService.getInstance().getRecentChats(completion: {(chatList, err) in
guard err == nil else {
print("False with code: \(String(describing: err?.mErrorCode)) and message: \(err?.mErrorMessage)")
return
}
// TODO: write your code here, chatList's type is [Chat]
})
- Create new chats:
PTChatService.getInstance().createNewChat(completion: {(chat, err) in
guard err == nil else {
print("False with code: \(String(describing: err?.mErrorCode)) and message: \(err?.mErrorMessage)")
return
}
//TODO: write your code here
})
- Load all previous messages in a chat:
PTChatService.getInstance().getMessages(chatId: String?, completion: {(messages, err) in
guard err == nil else {
print("False with code: \(String(describing: err?.mErrorCode)) and message: \(err?.mErrorMessage)")
return
}
// TODO: write your code here, messages' type is [Message]
})
- Send a new message in a chat:
PTChatService.getInstance().sendMessage(chatId: String?, completion: {(message, err) in
guard err == nil else {
print("False with code: \(String(describing: err?.mErrorCode)) and message: \(err?.mErrorMessage)")
return
}
//TODO: write your code here
})
Updated over 2 years ago
What’s Next