To add Audio/Video Calling support in your application,
Include the MessageSDKBinding.iOS in the .cs file of your ViewController.
All the method calls will invoke their respective callback blocks as defined below.
1. Initialize the AVChat object :
AVChat avchat = new AVChat();
2. Send call request
Send Audio Video call request to the userID specified. (Ensure that userID cannot be nil or empty)
void SendAVChatRequestToUser(string userID, Action success, Action failure);
Return type: void
Callback Blocks:
(i). Action success response
Invocation: After audio video call request is sent successfully
Response: NSDictionary containing id of the user to whom audio video call request has been sent
Eg:
{
callID = "\"474a3e0baf0e3db251a2bc2a6a5b31a5\"";
userID = 5;
}
(ii). Action failure
Invocation: If an error occurs while sending audio video call request
Response: NSError containing error code and message
Usage:
private void OnSuccess(NSDictionary dict) {
Console.WriteLine("OnSuccess : " + dict);
}
private void OnFailure(NSError err) {
Console.WriteLine("OnFailure : " + err);
}
avChat.SendAVChatRequestToUser("5",
(dict) => { this.OnSuccess(dict); },
(err) => { this.OnFailure(err);});
3. Accept call request
Accept audio-video call request when AVCHAT_INCOMING_CALL message is received in the onAVChatMessageReceived callback block. (Ensure that userID specified should be same as the userID received in AVCHAT_INCOMING_CALL message and also userID cannot be nil or empty)
void AcceptAVChatRequestOfUser(string userID, Action success, Action failure);
Return type: void
Callback Blocks:
(i). Action response
Invocation: After sending audio video call acknowledgement request successfully
Response: NSDictionary containing id of the user to whom audio video call acknowledgement has been sent
Eg:
{
userID = 6;
}
(ii). Action failure
Invocation: If an error occurs while sending audio video call request
Response: NSError containing error code and message
Usage:
private void OnSuccess(NSDictionary dict) {
Console.WriteLine("OnSuccess : " + dict);
}
private void OnFailure(NSError err) {
Console.WriteLine("OnFailure : " + err);
}
avchat.AcceptAVChatRequestOfUser(”6”,
(dict) => { this.OnSuccess(dict); },
(err) => { this.OnFailure(err);});
4. Start audio video call
Start an audio-video call within the container view. This function has to be called after sending/accepting audio-video call request only. (Ensure that userID specified here should be the same while sending/accepting the request and also userID cannot be nil or empty)
void StartAVChatCallWithUser(string userID, UIView view,Action failure);
Return type: void
Callback Blocks:
(i). (void(^)(NSError *error))failure
Invocation: If an error occurs while starting audio video call request
Response: NSError containing error code and message
Usage:
avchat.StartAVChatCallWithUser(”6”,view,(err) => { this.OnFailure(err);});
5. End call
End audio-video call with the user corresponding to userID specified. (Ensure that userID specified should be same as given when starting the audio-video call and also userID cannot be nil or empty)
void EndAVChatCallWithUser(string userID, Action success, Action failure);
Return type: void
Callback Blocks:
(i). Action response
Invocation: After ending audio video call successfully
Response: NSDictionary containing id of the user with whom audio video call has been ended
Eg:
{
callID = 474a3e0baf0e3db251a2bc2a6a5b31a5;
userID = 6;
}
(ii). Action failure
Invocation: If an error occurs while ending audio video call request
Response: NSError containing error code and message
Usage:
private void OnSuccess(NSDictionary dict) {
Console.WriteLine("OnSuccess : " + dict);
}
private void OnFailure(NSError err) {
Console.WriteLine("OnFailure : " + err);
}
avchat.EndAVChatCallWithUser(”6”,
(dict) => { this.OnSuccess(dict); },
(err) => { this.OnFailure(err);});
6. Cancel call
Cancel audio-video call after sending a call request. (Ensure that userID specified should be same as given when sending the audio-video call request and also userID cannot be nil or empty)
void CancelAVChatCallWithUser(string userID, Action success, Action failure);
Return type: void
Callback Blocks:
(i). Action response
Invocation: After cancelling audio video call successfully
Response: NSDictionary containing id of the user with whom audio video call has been cancelled
Eg:
{
userID = 6;
}
(ii). Action failure
Invocation: If an error occurs while cancelling audio video call request
Response: NSError containing error code and message
Usage:
private void OnSuccess(NSDictionary dict) {
Console.WriteLine("OnSuccess : " + dict);
}
private void OnFailure(NSError err) {
Console.WriteLine("OnFailure : " + err);
}
avchat.CancelAVChatCallWithUser("6",
(dict) => { this.OnSuccess(dict); },
(err) => { this.OnFailure(err);});
7. Send busy call
Send busy call when AVCHAT_INCOMING_CALL_USER_BUSY message is received in the onAVChatMessageReceived callback block. (Ensure that userID specified should be same as the userID received in AVCHAT_INCOMING_CALL_USER_BUSY message and also userID cannot be nil or empty)
void SendBusyCallToUser(string userID, Action success, Action failure);
Return type: void
Callback Blocks:
(i). Action response
Invocation: After sending busy call successfully
Response: NSDictionary containing id of the user to whom busy tone has been sent
Eg:
{
userID = 6;
}
(ii). Action failure
Invocation: If an error occurs while sending busy tone
Response: NSError containing error code and message
Usage:
private void OnSuccess(NSDictionary dict) {
Console.WriteLine("OnSuccess : " + dict);
}
private void OnFailure(NSError err) {
Console.WriteLine("OnFailure : " + err);
}
avchat.SendBusyCallToUser("6",
(dict) => { this.OnSuccess(dict); },
(err) => { this.OnFailure(err);});
8. Reject call
Reject audio-video call request when AVCHAT_INCOMING_CALL message is received in the onAVChatMessageReceived callback block. (Ensure that userID specified should be same as the userID received in AVCHAT_INCOMING_CALL message and also userID cannot be nil or empty)
void RejectAVChatCallWithUser(string userID, Action success, Action failure);
Return type: void
Callback Blocks:
(i). Action response
Invocation: After rejecting audio video call successfully
Response: NSDictionary containing id of the user whose incoming audio video call request has been
rejected
Eg:
{
callID = 474a3e0baf0e3db251a2bc2a6a5b31a5;
userID = 5;
}
(ii). Action failure
Invocation: If an error occurs while sending busy tone
Response: NSError containing error code and message
Usage:
private void OnSuccess(NSDictionary dict) {
Console.WriteLine("OnSuccess : " + dict);
}
private void OnFailure(NSError err) {
Console.WriteLine("OnFailure : " + err);
}
avchat.RejectAVChatCallWithUser("6",
(dict) => { this.OnSuccess(dict); },
(err) => { this.OnFailure(err);});
9. Toggle Audio to ON(YES) or OFF(NO) state
void ToggleAudio(bool audioControlFlag);
Return type: void
Usage:
avchat.ToggleAudio(true);
10. Toggle Video to ON(YES) or OFF(NO) state
void ToggleVideo(bool videoControlFlag);
Return type: void
Usage:
avchat.ToggleVideo(true);
11. Switch between front and rear camera in a Video call
void SwitchCamera();
Return type: void
Usage:
avchat.SwitchCamera();
Please refer error codes for failure responses.
Not finding what you need?
The CometChat team is here to help!