// Create a messaging client object
// This object makes API calls to backend and processes responses
- (void)viewWillAppear:(BOOL)animated
{
IDTMConversationClient *client =
[[IDTMConversationClient alloc] initWithConversationId:@"chatId"];
;
}
// The AppManager singleton is the center access point to the SDK.
// The AppManager shall be initialized before using it. You can
// do it for example at the onCreate() lifecycle call.
AppManager.getInstance().init(context);
// do your stuff...
// use AppManager: get the ConversationManager instance
ConversationManager cm = AppManager.getConversationManager();
// do something with the ConversationManager...
private void createNewConversation() {
// create a contact from the native address book
Contact contact1 = new Contact(null, "Tom", "Sawyer", "+358123456789");
// get an already existed contact by its user id (when the contact exists in some conversations)
Contact contact2 = AppManager.getContactManager().getContact("USER_ID");
ArrayList<Contact> contacts = new ArrayList<>();
contacts.add(contact1);
contacts.add(contact2);
AppRequest createConvReq = AppManager.getConversationManager().createConversation(contacts, "family");
// Now you need to have have a ConversationListener implemented and registered
// to receive results to your placed AppRequest
Create a Conversation
Create a new conversation between two or more users.
// Send the message to the conversation
AppManager.getConversationManager().sendMessage("CONVERSATION_ID", "hello world!");
...
// Implement and register ConversationListener to receive messages from the backend.
ConversationListener cl = new ConversationListener() {
@Override
public void onMessagesStored(String conversationId, List<ChatMessage> messages) {
// display the new messages here
}
...
}
// set the listener to the conversation manager
AppManager.getConversationManager().addListener(cl);