To add Audio Calling support in your application,
Include the class <MessageSDKFramework/AudioChat.h> in the .h file of your class.
Initialize the AudioChat object:
AudioChat *audioChat = [[AudioChat alloc] init];
Method Available:
sendAudioChatRequestToUser
The method sends audio call resquest to a user from a logged-in user
Method Signature:
(void)sendAudioChatRequestToUser: (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 audio call request is sent successfully |
Response: | NSDictionary containing id of the user to whom audio 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 audio call request |
Response: | NSError containing error code and message |
Usage:
[cometchat sendAudioChatRequestToUser: @"5"
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
acceptAudioChatRequestOfUser
Allows you to accept an audio call request when AUDIO_INCOMING_CALL message
is received in the onAVChatMessageReceived callback of subscribeWithMode method of CometChat class.
Method Signature:
(void)acceptAudioChatRequestOfUser: (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 audio call acknowledgement successfully |
Response: | NSDictionary containing id of the user to whom audio 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 audio call acknowledgement |
Response: | NSError containing error code and message |
Usage:
[audioChat acceptAudioChatRequestOfUser: @”6”
callID: @"474a3e0baf0e3db251a2bc2a6a5b31a5"
success: ^(NSDictionary * response){/* Code Block */}
failure: ^(NSError * error){/* Code Block */}
];
startAudioChatWithCallID
Starts an audio call within a container view. This function has to be called after sending/accepting audio call request only.
Method Signature:
(void)startAudioChatWithCallID: (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 audio 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 audio call request |
Response: | NSError containing error code and message |
Usage:
[audioChat startAudioChatWithCallID: @”474a3e0baf0e3db251a2bc2a6a5b31a5”
inContainerView: containerView
failure:^(NSError * error){/* Code Block */}
];
endAudioChatWithUser
Ends an audio call corresponding to userID
and callID
Method Signature:
(void)endAudioChatWithUser: (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 audio call successfully |
Response: | NSDictionary containing id of the user and callID corresponding to the ended audio 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 audio call session |
Response: | NSError containing error code and message |
Usage:
[audioChat endAudioChatWithUser: @"6"
callID: @"474a3e0baf0e3db251a2bc2a6a5b31a5"
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
cancelAudioChatRequestWithUser
Allows initiator to call the outgoing call
Method Signature:
(void)cancelAudioChatRequestWithUser: (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 audio call successfully |
Response: | NSDictionary containing id of the user with whom audio 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 audio call request |
Response: | NSError containing error code and message |
Usage:
[cometchat cancelAudioChatRequestWithUser: @"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 AUDIO_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:
[cometchat sendBusyCallToUser: @"5"
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
rejectAudioChatRequestOfUser
Allows user to reject audio call. You can show an option to reject a call on receiving AUDIO_INCOMING_CALL_USER_BUSY
message in the onAVChatMessageReceived callback.
Method Signature:
(void)rejectAudioChatRequestOfUser: (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 audio call successfully |
Response: | NSDictionary containing id of the user whose incoming audio 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:
[cometchat sendAudioChatRequestToUser: @"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:
[audioChat toggleAudio:YES];
Please refer error codes for failure responses.