Blocking and Unblocking Users

Estimated reading time: 4 minutes

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

There are various ways a user can block another user. Mesibo Blocking and Unblocking APIs allow you to individually control each type of blocking.

  • Block messages from a user including all 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.
  • Block group messages from a user.
  • 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 provides a simple block() API that blocks and unblocks messaging, calls, profile, and online status views between users in one API call. Alternatively, your app can block individual features like messaging, group messaging, calls, videos 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:

Parameter Description
enable block (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 all 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 all 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 profile views. The blocked user will not be able to view the profile and online status of the user.

void blockProfileSubscription(boolean enable);

blockProfileSubscription 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.

blocking, messaging, retraction, delete, group messaging, disapppearing messages