To add Audio/Video Broadcast 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 AVBroadcast object :
private AVBroadcast avbroadcast = new AVBroadcast();
2. Send call request
Send Audio Video Broadcast call request to the userID specified. (Ensure that userID cannot be nil or empty)
void SendAVBroadcastRequestToUser(string userID,Action success, Action failure);
Return type: void
Callback Blocks:
(i). Action response
Invocation: After audio video broadcast call request is sent successfully.
Response: NSDictionary containing id of the user to whom audio video broadcast request has been sent.
Eg:
{
callID = 2be701b036ff9b6e3085d35049e59483;
userID = 5;
}
(ii). Action failure
Invocation: If an error occurs while sending audio video broadcast 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);
}
avbroadcast.SendAVBroadcastRequestToUser("5",
(dict) => { this.OnSuccess(dict); },
(err) => { this.OnFailure(err);});
3. Start audio video broadcast
Start an audio-video broadcast within the container view. This function has to be called after sending/accepting audio-video broadcast 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 StartAVBroadcastWithInitiator(bool initiator, string callID, UIView view, Action failure);
Return type: void
Callback Blocks:
(i). Actionfailure
Invocation: If an error occurs while starting audio video broadcast request.
Response: NSError containing error code and message.
Usage:
Sender
private void OnSuccess(NSDictionary dict) {
Console.WriteLine("OnSuccess : " + dict);
}
private void OnFailure(NSError err) {
Console.WriteLine("OnFailure : " + err);
}
avbroadcast.StartAVBroadcastWithInitiator(true,
(dict) => { this.OnSuccess(dict); },
(err) => { this.OnFailure(err);});
Receiver
private void OnSuccess(NSDictionary dict) {
Console.WriteLine("OnSuccess : " + dict);
}
private void OnFailure(NSError err) {
Console.WriteLine("OnFailure : " + err);
}
avbroadcast.StartAVBroadcastWithInitiator(false,
(dict) => { this.OnSuccess(dict); },
(err) => { this.OnFailure(err);}););
4. End call
End audio-video broadcast with the user corresponding to userID specified. (Ensure that userID specified should be same as given when starting the audio-video broadcast and also userID cannot be nil or empty)
void EndAVBroadcastWithUser(string userID, Action success, Action failure);
Return type: void
Callback Blocks:
(i). Action successresponse
Invocation: After ending audio video broadcast successfully.
Response: NSDictionary containing id of the user with whom audio video broadcast has been ended.
Eg:
{
success = 1;
}
(ii). Actionfailure
Invocation: If an error occurs while ending audio video broadcast 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);
}
avbroadcast.EndAVBroadcastWithUser("6,"
(dict) => { this.OnSuccess(dict); },
(err) => { this.OnFailure(err);});
5. Switch between front and rear camera in a Video call
void SwitchCamera();
Return type: void
Usage:
avbroadcast.SwitchCamera();
Please refer error codes for failure responses.
Not finding what you need?
The CometChat team is here to help!