Get your messaging app
to your users faster.

CODE SAMPLES

Take a look under the hood of our open SDK, select an action below.

Create a Messaging Client

First you need to create a Messaging client, which provides access to the RESTful Messaging API methods.

// 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"];
    ;
}
6
// 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...
// Create flow object to help with conversation creation. 
// Add contacts to flow object's contactFields property. 
// Then create group conversation with these contacts.
- (void)createConversation:(NSArray *)contactFields
{
    IDTMCreateConversationFlow *flow = [IDTMCreateConversationFlow instance];
    flow.contactFields = [NSArray arrayWithArray:contactFields];
    [flow createConversationWithSuccessCompletion:^(NSString *objectId) {
        // update UI
    }];
    } andFailureHandler:^{
        // handle error
    }];
}
6
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 a Message

Create a message and send it to all members of the conversation.

// Send text message to the conversation object
- (void)sendMessage:(NSString *)message
{
    [self.client sendTextMessage:message 
                  inConversation:self.conversation
                       inContext:[[IDTMContextManager sharedManager] mainContext]];
}

// Send JPG image to the conversation.
- (void)sendImage:(NSData *)image
{
    [self.client sendAttachment:UIImageJPEGRepresentation(image, .5)
         withPlaceHolderMessage:nil ofMimeType:@"image/jpeg" 
                 withCompletion:^{
                     // update UI
                 }];
}
6
// 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);

Now seeking rock star developers.