Messaging APIs - Introduction and Basic Usage

Estimated reading time: 4 minutes

mesibo allows you to send and receive any arbitrary message in real-time. Your message could just the plain text, binary data, or a rich message with any arbitrary file (image, audio, video, doc, etc) and various predefined and custom message fields. mesibo also allows you to geotag your messages by including location information.

In addition to message content, a message has various properties, for example, message ID, status, origin, expiry time by which it should be delivered, retention duration, etc. We will explore those in detail in subsequent sections. You can also refer to the Message Properties and Message Functions documents for complete reference.

In this section, we will describe basic syntax on how to send and receive messages.

Sending Messages

To send messages, you only need to create a MesiboMessage object using the destination profile, add your content (text message, files, location, etc.), set message properties if requires, and call send method. You can create a MesiboMessage object by calling

Creating a Message Object

MesiboMessage message = profile.newMessage();


MesiboMessage message = new MesiboMessage(profile);

where the profile is the user or group profile to whom you want to send a message. Once you create a MesiboMessage object, all you need to do is to add your message content and call send(). There is no difference between how you send messages to an individual user or a group, the destination is set based on the profile you have used to create MesiboMessage.

Send a Plain Text Message

MesiboMessage msg = profile.newMessage();
msg.message = "My First Mesibo Message";

Add Media and Files to your message

You can also add a file using the file path, URL, or Image Object (Android Bitmap, iOS UIImage, etc) as required. For example,

msg.title = "This is a rich message";

Geotag your Messages

You can also geotag your messages by adding location information,

msg.latitude = 37.4275;
msg.longitude = 122.1697;

Add Custom Fields to your Messages

Not only the predefined fields, you can also add custom fields as required by your apps to the message:

msg.setString("Custom1", "some string value");
msg.setInt("Custom2", 123);

Sending Binary Messages

You can also send arbitrary binary messages. Note that, when you send binary messages, all other fields are ignored.

MesiboMessage msg = profile.newMessage(); = data; // binary data array

Receiving Messages, Message Status, and Updates

You need to implement the mesibo MessageListener class to receive messages, the status of messages you sent, and any other message updates. As soon as the mesibo API receives messages for you or the status or any updates, it will call one of the listeners of the MesiboMessage object.

void Mesibo_onMessage(MesiboMessage msg) {  
	// You will receive messages here
	return true;
void Mesibo_onMessageUpdate(MesiboMessage msg) {  
        // You will receive message updates here
       return true;

void Mesibo_onMessageStatus(MesiboMessage msg) {
        // You will receive status of sent messages here


Mesibo maintains the weak reference for all messages and hence you will get the same object in all three listeners when they are referring to the same message. However, there are three different listeners so you can optimize the action. For example, you can safely ignore Mesibo_onMessageUpdate update if you are not rendering that message currently. Since mesibo maintains message references for you, you will always have updated information whenever you are rendering that message in the future. However, if the Mesibo_onMessage is received, you may want to show the new message. These are just suggestions and actual logic and usage are entirely up to you.

In the next few sections, we will learn about more operations like setting properties, replies, forwarding, etc.

messaging api, android messaging api, real-time chat api, messaging api for ios