AVChat

To add Audio/Video Calling support in your app,

Include the class <MessageSDKFramework/AVChat.h> in the .h file of your class.

Initialize the AVChat object:

AVChat *avChat =  [[AVChat alloc] init];

Methods Available:

Method Description
sendAVChatRequestToUser The method allows user to initiate video call resquest to a user from a logged-in user
acceptAVChatRequestOfUser The method allows logged-in user to accept an video call
startAVChatWithCallID The method allows loggedin user to start video call
endAVChatWithUser The method allows you end the call
cancelAVChatCallWithUser The method allows initiator to call the outgoing call
sendBusyCallToUser The method allows you to send busy notification to a user
rejectAVChatCallWithUser The method allows you to reject an incoming call
toggleAudio The method allows you to mute/unmute audio
toggleVideo The method allows you to mute/unmute video
switchCamera The method allows you to switch camera

sendAVChatRequestToUser

The method initiates video call resquest to a user from a logged-in user
Method Signature:

 (void)sendAVChatRequestToUser: (NSString *) userID
                       success: (void(^)(NSDictionary *response)) response
                       failure: (void(^)(NSError *error)) failure;

Arguments:

userID:

The userid of a user with whom you want to initiate a call as NSString datatype.

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: After video call request is sent successfully
Response: NSDictionary containing id of the user to whom video call request has been sent and callID

Sample Response:

{
  callID = "474a3e0baf0e3db251a2bc2a6a5b31a5";  
  userID = 5;
}

failure

A callback method

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If an error occurs while sending video call request
Response: NSError containing error code and message

Usage:

[avChat sendAVChatRequestToUser: @"5"
                        success: ^(NSDictionary *response){/* Code Block */}
                        failure: ^(NSError *error){/* Code Block */}
];

acceptAVChatRequestOfUser

Allows you to accept an video call request when AVCHAT_INCOMING_CALL message is received in the onAVChatMessageReceived callback of subscribeWithMode method of CometChat class.
Method Signature:

 (void)acceptAVChatRequestOfUser: (NSString *)userID
                          callID: (NSString *)callID
                         success: (void(^)(NSDictionary *response)) response
                         failure: (void(^)(NSError *error)) failure;

Arguments:

userID

The userid of a user who has initiated a call with you as NSString datatype.

callID

The id of the incoming call

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: After sending video call acknowledgement successfully
Response: NSDictionary containing id of the user to whom video call acknowledgement has been sent

Sample Response:

{  
 userID = 6;
}

failure

A callback method

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If an error occurs while sending video call acknowledgement
Response: NSError containing error code and message

Usage:

[avChat acceptAVChatRequestOfUser: @"6"
                           callID: @"474a3e0baf0e3db251a2bc2a6a5b31a5"
                          success: ^(NSDictionary * response){/* Code Block */}
                          failure: ^(NSError * error){/* Code Block */}
];

startAVChatWithCallID

Starts an video call within a container view. This function has to be called after sending/accepting video call request only.
Method Signature:

 (void)startAVChatWithCallID: (NSString *)callID
             inContainerView: (UIView *)container
                     failure: (void(^)(NSError * error))failure;

Arguments:

callID

The id of the call as NSString datatype.

inContainerView

The reference of the UI Container in which video call UI should be placed as UIView datatype.

failure

A callback method

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If an error occurs while sending video call request
Response: NSError containing error code and message

Usage:

[avChat startAVChatWithCallID: @"474a3e0baf0e3db251a2bc2a6a5b31a5"
              inContainerView: containerView
                      failure: ^(NSError * error){/* Code Block */}
];

endAVChatWithUser

Ends an video call corresponding to userID and callID
Method Signature:

(void)endAVChatWithUser: (NSString *)userID
                 callID: (NSString *)callID
                success: (void(^)(NSDictionary *response))response
                failure: (void(^)(NSError *error))failure;

Arguments:

userID

The userid of a user with whom you want to initiate a call as NSString datatype.

callID

The id of a call as NSString datatype.

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: After ending video call successfully
Response: NSDictionary containing id of the user and callID corresponding to the ended video call session

Sample Response:

{
  callID = "474a3e0baf0e3db251a2bc2a6a5b31a5";  
  userID = 5;
}

failure

A callback method

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If an error occurs while ending video call session
Response: NSError containing error code and message

Usage:

[avChat endAVChatWithUser: @"6"
                   callID: @"474a3e0baf0e3db251a2bc2a6a5b31a5"
                  success: ^(NSDictionary *response){/* Code Block */} 
                  failure: ^(NSError *error){/* Code Block */}
];

cancelAVChatRequestWithUser

Allows initiator to call the outgoing call
Method Signature:

(void)cancelAVChatRequestWithUser: (NSString *)userID
                          success: (void(^)(NSDictionary *response))response
                          failure: (void(^)(NSError *error))failure;

Arguments:

userID

The userid of a user with whom you had initiated a call as NSString datatype.

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: After cancelling video call successfully
Response: NSDictionary containing id of the user with whom video call has been cancelled

Sample Response:

{
  userID = 6;
}

failure

A callback method

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If an error occurs while sending video call request
Response: NSError containing error code and message

Usage:

[avChat cancelAVChatRequestWithUser: @"6"
                            success: ^(NSDictionary *response){/* Code Block */}
                            failure: ^(NSError *error){/* Code Block */}
];

sendBusyCallToUser

Sends busy call notification to a user who had made a call. You can use this method to notify the user that you are already enganed in another call. The message AVCHAT_INCOMING_CALL_USER_BUSY message is received in the onAVChatMessageReceived callback indicates that the logged-in user is busy with another call.
Method Signature:

 (void)sendBusyCallToUser: (NSString * )userID
                  success: (void(^)(NSDictionary *response))response
                  failure: (void(^)(NSError *error)) failure;

Arguments:

userID

The userid of a user with whom you want to initiate a call as NSString datatype.

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: After sending busy call successfully
Response: NSDictionary containing id of the user to whom busy notification has been sent

Sample Response:

{  
  userID = 6;
}

failure

A callback method

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If an error occurs while sending busy notification
Response: NSError containing error code and message

Usage:

[avChat sendBusyCallToUser: @"5"
                   success: ^(NSDictionary *response){/* Code Block */}
                   failure: ^(NSError *error){/* Code Block */}
];

rejectAVChatRequestOfUser

Allows user to reject video call. You can show an option to reject a call on receiving AVCHAT_INCOMING_CALL_USER_BUSY message in the onAVChatMessageReceived callback.
Method Signature:

 (void)rejectAVChatRequestOfUser: (NSString *) userID
                         success: (void(^)(NSDictionary *response)) response
                         failure: (void(^)(NSError *error)) failure;

Arguments:

userID

The userid of a user with whom you want to initiate a call as NSString datatype.

success

A callback method

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: After rejecting video call successfully
Response: NSDictionary containing id of the user whose incoming video call request has been rejected

Sample Response:

{
  callID = "474a3e0baf0e3db251a2bc2a6a5b31a5";  
  userID = 5;
}

failure

A callback method.

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If an error occurs while sending busy notification
Response: NSError containing error code and message

Usage:

[avChat rejectAVChatRequestOfUser: @"5"
                          success: ^(NSDictionary *response){/* Code Block */}
                          failure: ^(NSError *error){/* Code Block */}
];

toggleAudio

The method allows user to mute/unmute Audio
Method Signature:

(void)toggleAudio: (BOOL)audioControlFlag;

Arguments:

audioControlFlag:

A boolean value. YES indicates unmute and NO indicates mute
Usage:

[avChat toggleAudio: YES];

toggleVideo

The method allows user to mute/unmute video
Method Signature:

(void)toggleVideo: (BOOL)videoControlFlag;

Arguments:

videoControlFlag

A boolean value. YES indicates unmute and NO indicates mute
Usage:

[avChat toggleVideo: YES];

switchCamera

The method allows user to switch camera
Method Signature:

(void)switchCamera:

Usage:

[avChat switchCamera];

Please refer ‎error codes for failure responses.

  • Was this helpful?
  • Yes   No