Mesibo Profile Management and Syncronization

As described in the previous section, a profile represents a user or a group. The profile also allows you to associate human-readable information such as name, description, picture, status, presence information, etc. with a user or a group.

There are three types of profiles:

Self Profile

The profile of the logged-in user. The user can modify self profile and publish it so that other users can view the profile information. All other users who have subscribed to this user's profile will get an instant notification of the profile change. The logged-in user can set the privacy of the profile to override the subscription, for example, only limited users can access the profile, not all subscribers.

User Profile

The profile of another user. Any user can request the profile of another user. If the profile exists locally, Mesibo API will instantly return it. If not, it will return an empty profile and also request the mesibo server for the profile. If the server has the profile and the user is allowed to access it, the user will be notified of the updated profile in a listener callback (explained later). Mesibo API will also invoke a callback whenever there is an update. Note that, a user cannot modify the profile of another user.

Group Profile

Group Profile is the same as User Profile described above except that the group profile can be modified only by the group owner or the admin having permission to modify it. All the group members will get instant notification of the profile update.

Let's get started on how to access and set profiles.

Getting Profile of another User or a Group

You can get the profile of any user or a group by calling getProfile API. There are two possibilities:

  1. If the profile exists locally, mesibo API will instantly return it.
  2. If not, mesibo API will return an empty profile and also request the mesibo server for the profile. Depending on the permissions set by the user, the server may send a full, restricted, or empty profile. When the profile is received from the server, mesibo API will invoke one of the listeners to let you know about the profile update. We will cover listeners later in this document.

Note: You will receive a blank profile if you do not have access to a profile as per visibility rules set by the user whose profile you are trying to access (explained later). However, you can still subscribe (explained below) to the profile and wait for the user to change the visibility settings in the future so that it is accessible to you.

In Java,

MesiboProfile profile;
profile = Mesibo.getProfile(address);

String name = profile.getName();
String firstname = profile.getFirstName();
Bitmap tn = profile.getThumbnail();

In Kotlin

var mProfile: MesiboProfile? = null
mProfile = Mesibo.getProfile(address)

String name:String = profile.getName();
String firstname:String = profile.getFirstName();
var tn:Bitmap = profile.getThumbnail();

In Objective-C,

MesiboProfile *profile;
profile = [MesiboInstance getProfile:address groupid:0];

// get profile information
NSString *name = [profile getName];
NSString *firstname = [profile getFirstName];
UIImage *tn = [profile getThumbnail];

In Swift,

var profile: MesiboProfile
profile = Mesibo.getInstance().getProfile(nil, groupid: 96568)

// get profile information
var name: String = profile.getName();
var firstname: String = profile.getFirstName();
var image: UIImage = profile.getThumbnail()

In Javascript

var profile;
profile = Mesibo.getProfile(address);

var name = profile.getName();
var tn = profile.getThumbnail();

Subscribing to a Profile

You can subscribe to a profile so that you can be notified whenever changes are made to the profile. Note that, every time you call getProfile and if the profile does not exist locally, you will be automatically subscribed to the profile updates. However, you can change the subscription status anytime later by calling subscribe API. For example,


After subscribing to a profile, you will be notified whenever the profile is updated through the listeners - either through the global listener or per profile listener. See the section on Listeners to learn more about this.

Overriding Profile Information (Local Override)

You can not change profile information of another user. However, you can override the profile information set by the user or group admin by calling various set methods. These changes will be local only and will not affect the global profile. For example,

profile.setName("New Name");; // save local changes to the database

The next time, getName API will return the updated profile information.

To restore a property to the original value and undo your local changes, set the property to null.

To restore the entire profile object to its original values and undo all local changes, you can call the removeLocalProfile method of the profile object.

Setting (Publishing) your Profile

You can publish your profile so that other users will be able to access it as explained above. To publish a profile, you need to access MesiboSelfProfile object and set the required information.

To get your self profile use getSelfProfile. You can then modify properties of this profile, such as name, photo, address, etc.

MesiboSelfProfile selfProfile = Mesibo.getSelfProfile();

selfProfile.setName("John Doe");
selfProfile.setStatus("Hey! I am using this app.");
selfProfile.setImage(bitmap);; // publish 

Every time you save the self profile, it will be published and all the subscribers will be automatically notified about it.

Profile Visibility

In addition to other information, you can control who can view your profile by setting the profile visibility. It can be one of the following:


Anyone and everyone can view your profile. Any user can get your profile and subscribe to updates. By default, the profile visibility is PUBLIC.


Only users who you have added as your contact will be able to get your profile and subscribe to your profile updates. You can add a profile as your contact using the setContact method. You can further specify what information a particular contact has access to. Refer to the Contact Synchronization section below to learn more about contacts APIs.


Only you will have access to your profile and it will be invisible to others


Profile Publishing Mode

By default, every time you publish your profile, it will be synchronized immediately and all the valid subscribers will be notified immediately. However, you can change this behavior to on-demand by setting the publish mode. There are two modes:

Real-Time Publishing

As soon as you publish the profile all interested users will be notified immediately.

Lazy / On-demand Publishing

Once you publish your profile it will be updated on the server but other users will not be notified immediately. Instead, they will be notified along with other profiles or messages. This consumes lesser bandwidth than the Real-Time publishing. For example, in the case of a messaging app, if you have 1000 contacts using the app, and all thousand contacts have updated their profile in Lazy mode, the changes will not be reflected immediately. When you open their profile to view them or when you open their chat view and send/receive messages, their displayed profile can be updated.


Publishing or Updating Group Profile

Publishing group profile is the same as publishing self profile except that you need to get Group Profile instead of Self Profile and you must be either group owner or an admin with modify permissions.

Saving a Profile

You also save a profile locally to the local database using the save method.

There are three possibilities when you are calling save on a profile object:

  1. If the profile is a self profile, the save method saves the profile to the local database and then publishes the latest profile to the server.
  2. If the profile is a group profile and you have modification permission, the save method saves the profile to the local database and then publishes the latest profile to the server.
  3. Otherwise, the save method saves the profile into the local database.

Profile Image Handling

One can set the display picture of a profile using the following methods in a profile object:

  • setImage, Set the image bitmap
  • setImageFromFile, Set image from the path to the image file
  • setImageUrl, Set the file url of the image. For example, if you have uploaded the file to an external file server(Ex: Amazon S3 bucket) and obtained a url, you can directly set it.

If you set the image bitmap using setImage or setImagePath, mesibo will upload it to a file server and automatically generate a file url for you. To custom handle file uploads, you need to set up your own file server(Example, an Amazon S3 bucket) and implement an upload handler. Else, mesibo will use the default file handler to upload the image to mesibo servers. Once, the upload is complete mesibo will set the image url in the profile object and save.

Similarly, On the remote end, when someone gets your profile object, mesibo will download the image Once the download is complete, the file is cached. A thumbnail will also be automatically generated and saved for the profile, which can be accessed using the getThumbnail method.

to optimize bandwidth, mesibo only downloads images when needed. The image data may not be updated if you haven't accessed a profile for a long time. For example, if a profile is updated and you use getImage, if the download is not complete you may get null. But, once the download is complete you will be notified through the listeners that the profile is updated. You can then read the latest profile object and display the updated profile picture.


The Profile API consists of the following:

  • MesiboProfile, To publish and subscribe to a profile, use methods from the MesiboProfile class. The MesiboSelfProfile class is a subclass of MesiboProfile