Making a call

Make a call#

Call feature is essential for the modern day communication. Call sdk allows users to make a one to one audio/video call with the another sdk user.

Note: Check Permissions Before Working in Call Feature.

Required permissions#

For audio call, the below permissions:

Microphone Permission

For video call, we need below permissions:

Microphone Permission
Camera Permission

Make a Voice Call#

To make a one to one voice call, call the below method.

Mirrorfly.makeVoiceCall(USER_JID).then((isSuccess) {
if (isSuccess) {
}
}).catchError((e) {
debugPrint("#Mirrorfly Call Exception $e");
});
ArgumentTypeDescription
USER_JIDStringJid of another registered user
caution

If one to one call feature unavailable for your plan then it will throw 403 exception.

Make a video call#

Make video call feature allows users to make a one to one video call with the another sdk user. You can make a video call using the below method.

Mirrorfly.makeVideoCall(USER_JID).then((isSuccess) {
if (isSuccess) {
}
}).catchError((e) {
debugPrint("#Mirrorfly Call $e");
});
ArgumentTypeDescription
USER_JIDStringJid of another registered user
caution

If one to one call feature unavailable for your plan then it will throw 403 exception.

Receiving a incoming audio/video call#

Whenever you receive the audio/video call from the another sdk user, it will be reported to SDK and Incoming Call Notification will be displayed from Plugin.

Answer the incoming call#

Once the Call is being presented with Accept/Reject Call buttons, we can either choose to attend or reject the call. If we attend the call the below event listener onCallStatusUpdated will be triggered, and the status will be of the case Attended.

Mirrorfly.onCallStatusUpdated.listen((event) {
var statusUpdateReceived = jsonDecode(event);
var callMode = statusUpdateReceived["callMode"].toString();
var userJid = statusUpdateReceived["userJid"].toString();
var callType = statusUpdateReceived["callType"].toString();
var callStatus = statusUpdateReceived["callStatus"].toString();
});
ArgumentTypeDescription
callModeStringFor this callMode OneToOne or groupCall will be returned from SDK
userJidStringFor this userJID will be returned from SDK
callTypeStringFor this callType Video or Audio will be returned from SDK
callStatusCallStatusAn enum class defines the current status of the call

Note: if the required permissions are not available then call be will be automatically declined even though you answered a call in Android.

Decline the incoming call#

Whenever you receive the audio/video call from the another sdk user, depending upon the android version, you activity may be started so whenever user presses decline button from your call UI , you need to call the below sdk method to decline the call and notify the caller.

Mirrorfly.declineCall().then((isSuccess) {
});

Disconnect the ongoing call#

Whenever you make the audio/video call to the another sdk user and you just want to disconnect the call before getting connected or If you want to just disconnect a connected call after the end of conversation, whenever user presses the disconnect button from your call UI , you need to call the below sdk method to disconnect the call and notify the caller.

Mirrorfly.disconnectCall().then((isSuccess) {
});
info

Call Sdk requires chat sdk integration for user management.