Blocking and Unblocking Users

Blocking and Unblocking APIs allow a user to block and unblock communication with another user.

There are multiple ways a user can block another user. Mesibo Blocking and Unblocking APIs allow you to individually control each type of blocking. Depending on your app, you can block one or multiple aspects of the communication.

  • Block all messages from a user including text messages, binary messages, file messages, presence, activity, etc. However, if the blocked user sends a message to the group, it will not be blocked.
  • Block group messages from a user. Other group members will still get the message.
  • Block voice and video calls
  • Block video calls
  • Block profile views. The blocked user will not be able to view the profile and online status of the user.

Mesibo also provides a combined block() API that blocks and unblocks messaging, calls, profile views, and online status views between users in one API call. Alternatively, your app can block individual features like messaging, group messaging, calls, video calls, profile, and online status view as per your application requirements.

Block Messages, Calls, and Profile Views in one shot

The user can block Messages, Calls, and Profile Views in one shot by calling block or toggleBlock API of MesiboProfile. If you prefer to block individual features, you can use APIs used in the next sections.

void MesiboProfile.block(boolean enable);
boolean MesiboProfile.toggleBlock();

block takes the following parameters:

ParameterDescription
enableblock (true) or unblock (false) messages, calls and profile views.

For example, in Java and Kotlin

profile = Mesibo.getProfile(address);

profile.block(true);
profile.save();

In Objective-C,

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

[profile block:YES];
[profile save];

In Swift,

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

profile.block(true);
profile.save();

In Javascript

profile = Mesibo.getProfile(address);

profile.block(true);
profile.save();

toggleBlock does not take any parameters. It toggles the current block status.

profile = Mesibo.getProfile(address);

profile.toggleBlock();
profile.save();

Blocking Messages

Block all messages from a user including text messages, binary messages, file messages, presence, activity, etc. However, if the blocked user sends a message to a common group, it will not be blocked. Blocking messages also blocks online status and the blocked user will not be able to add user to any group.

void blockMessages(boolean enable);

blockMessages has the same parameters as the block API described above. Refer block API description above for details and examples.

Blocking Group Messages

Block all group messages from a user including text messages, binary messages, file messages. presence, activity, etc.

void blockGroupMessages(boolean enable);

blockGroupMessages has the same parameters as the block API described above. Refer block API description above for details and examples.

Blocking Voice and Video Calls

Block all one-to-one calls from a user including voice and video calls.

void blockCalls(boolean enable);

blockCalls has the same parameters as the block API described above. Refer block API description above for details and examples.

Blocking only Video Calls

Block all one-to-one video calls from a user. This API has no effect if all calls are blocked using blockCalls API.

void blockVideoCalls(boolean enable);

blockVideoCalls has the same parameters as the block API described above. Refer block API description above for details and examples.

Blocking Profile Views

Block user from viewing and subscribing to users' profile. The blocked user will not be able to view the profile and online status of the user.

void blockProfile(boolean enable);

blockProfile has the same parameters as the block API described above. Refer block API description above for details and examples.

Getting Block Status

You can get the block status by using one of the following APIs.

boolean isBlocked();
boolean isMessageBlocked();
boolean isCallBlocked();
boolean isGroupMessageBlocked();
boolean isVideoCallBlocked();
boolean isProfileSubscriptionBlocked();

isBlocked returns true if messaging, calls or profile subscription is blocked. Other APIs returns individual status.

Deleting from the Contact List and Delete Messages

In addition to blocking, a user can request a remote user to delete the user from their contact list and delete all the messages. Note that, the app should allow a contact delete policy as described in message retraction APIs.

On the remote end, Mesibo_onProfileUpdated will be invoked when the sender profile is deleted which can be used for updating UI, if requires.

void requestProfileRemoval();

requestProfileRemoval does not take any parameters.