Enable messaging

  1. 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]
})
  1. 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
})
  1. 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]
})
  1. 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
})

What’s Next