Avaya Client SDK

< Back to Package Overview

Making an audio call

Using the Avaya Client SDK, you can easily integrate the ability for users of your application to make and receive audio or video calls.

To make an audio call, you must complete the following activities:

  • Create a call object and initialize the details for the call
  • Implement the call delegate to monitor for call progress events
  • Start the call

Create a call object

Creating a CSCall object allows you to set various properties for the call before the call is actually placed.

The CSCall object is created from the CSCallService.

CSCallService* callService = user.callService;
CSCall* call = [callService createCall];

You can specify the phone number to dial by setting the remote address.

call.remoteAddress = callNumber;

Implement the call delegate

To monitor call progress events, the <CSCallDelegate> protocol provided by the CSCall object can be used. This protocol provides notification as the call state changes.

Your application can define an object that implements the <CSCallDelegate> methods and can add it to the CSCall object to receive callback notifications.

@interface AppCallHandler() 
...
@end

@implementation AppCallHandler

    - (void)callDidStart:(CSCall *)call {
        // Called to report that call has started (ie, call is in progress).
        // Add code here to update the UI as appropriate.
    }

    - (void)callDidBeginRemoteAlerting:(CSCall *)call 
                        withEarlyMedia:(BOOL)hasEarlyMedia {
        // Called to report that an outgoing call is ringing at the far end.
        // Add code here to update the UI as appropriate.
    }

    - (void)callDidEstablish:(CSCall *)call {
        // Called to report that an outgoing call has been established 
        // (ie, far end has answered and speechpath has been established).
        // Add code here to update the UI as appropriate.
    }

    - (void)callDidEnd:(CSCall *)call reason:(CSCallEndReason)reason {
        // Called to report that call has ended.
        // Add code here to update the UI as appropriate.
    }

    - (void)call:(CSCall *)call didFailWithError:(NSError *)error {
        // Called to report that call has failed and the failure reason
        // is described in the error parameter.
        // Add code here to update the UI as appropriate.
    }

    ...

@end

You can instantiate an application call handler (AppCallHandler) and add that as a delegate to the call.

AppCallHandler *callHandler = [[AppCallHandler alloc] init];
call.delegate = callHandler;

Start the call

Once a call delegate has been added, you can call the start method on the CSCall object. Call progress events will be provided through the <CSCallDelegate> protocol.

[call start];

End the call

To terminate the call, you can call the end method on the CSCall object.

[call end];

The callDidEnd:reason: callback event is sent to the call delegate when the call has been ended. You can use this event to update the UI of your application.