Sending Online and Offline Status

As described in the Mesibo presence APIs, users can show their Online and Offline status to other users or group members by sending Online and Offline presence. However, modern mobile OSs can suspend or kill your app without notice, and hence your app may not get an opportunity to update other users with the status. Since mesibo API knows when you are online and offline, we recommend leaving this task of sending Online and Offline presence to mesibo. You only need to configure when to show online status and privacy as described in the next section.

Automatically Sending Online and Offline Status

Although you can send Online and Offline activities manually, mesibo let you automate the entire task of sending online and offline status depending on your app state. You only need to select the online mode, target, and privacy options.

Online Modes

You can select one of the following modes to decide when your app should show your users Online.

Send online status when the user is logged in and actively using the app (the app is in the foreground). Mesibo sends offline when the app moves to the background. This is the default mode and most appropriate for most applications.

Show Online on Login

Send online status when the user logs in and send offline when the user disconnects. In this mode, the user may be shown online even though the user is not actively using the app, for example, the user was logged in while the app is in the background. Hence it is not recommended to use this mode unless your application demands it.

Manual

Mesibo calls a callback function when someone requests the online status. Depending on your application logic, you can send online status or ignore it.

You can select online mode by calling setOnlineMode API.

void setOnlineMode(int mode);

setOnlineMode takes the following parameters:

ParameterDescription
modeOnline Mode

For example,

setOnlineMode(MESIBO_ONLINEMODE_FOREGROUND);

Other options are MESIBO_ONLINEMODE_LOGIN and MESIBO_ONLINEMODE_MANUAL.

Target Audience for Online status

By default, the online status is sent to a special group MESIBO_GROUP_PROVSUBSCRIBERS, which results in sending the status to all users who have subscribed to your online status. You can change this to any other special group or any group you have created by calling setOnlineTarget API.

void setOnlineTarget(long groupid);

setOnlineTarget takes the following parameters:

ParameterDescription
groupidGroup ID. It can be a special group ID or any other group that you have created

For example,

setOnlineGroup(MESIBO_SPECIALGROUP_PROVSUBSCRIVERS);

Refer to the group management API documentation to learn about the special group.

Online status Privacy

By default, the online status is sent to anyone who has requested it. You can change the privacy to contacts only by calling setOnlinePrivacy API. Another way to change privacy is to select the target which sends to contacts only.

void setOnlinePrivacy(int privacy);

setOnlineTarget takes the following parameters:

ParameterDescription
privacyPrivacy mode

For example,

setOnlinePrivacy(MESIBO_ONLINESTATUS_PUBLIC);