<

Getting started with Plivo iOS SDK v2 (Beta)

Plivo iOS SDK v2 provides a way to integrate the ability to make and receive voice calls in any iOS application. The SDK currently supports iOS versions 8 and above including iOS 11.

This guide helps you seamlessly integrate calling using Plivo in your app, make outgoing calls and receive incoming calls using the SDK.

Step 1: Creating an Endpoint

You need a Plivo account and need to create an endpoint to start using the iOS SDK. An endpoint facilitates making and receiving calls from the iOS client. More information on what an endpoint is and where it can be used can be found in the endpoint tutorial. Create an endpoint as required. You can automate creation of endpoints if required using our REST API. Please refer to our API documentation for endpoint for more details.

Step 2: Installing the SDK

You can install this SDK either manually or by using Cocoapods. Please follow this manual installation guide for installing the SDK manually.

In case you want to install from Cocoapods please use the following command for installation.

pod 'PlivoVoiceKit'

Step 3: Handling calls with iOS SDK

This section provides an overview of how to make outgoing calls and receive incoming calls using the SDK. We have also created a sample application for your reference that has code snippets for all the functionalities that the SDK provides.

Make outgoing calls

You can make an outgoing call from the device by registering using the endpoint credentials you had set in Step 1. The ‘createOutgoingCall’ API should be used to make an outgoing call. Here is the code snippet for the same.

1
2
3
4
5
6
7
8
9
NSString *username = @"Tatooine";
NSString *password = @"Jabba";
PlivoEndpoint *endpoint = [[PlivoEndpoint alloc] init];
[endpoint login:username AndPassword:password];

NSString *toURI = @"sip:Coruscant@phone.plivo.com";

PlivoOutgoing *outgoing = [endpoint createOutgoingCall];
[outgoing call:toURI];

More details about the API can be found in our SDK reference.

Receive incoming calls

This SDK supports Apple Pushkit and Callkit which allows the app to receive incoming calls even if it is not active. In order to make use of Pushkit and Callkit you need to configure your push credentials in Plivo account. Here is a step by step guide on setting up the Push credentials.

The incoming call can be answered and handled using the codesnippet below.

1
2
3
4
5
6
7
8
9
10
11
NSString *username = @"Tatooine";
NSString *password = @"Jabba";
PlivoEndpoint *endpoint = [[PlivoEndpoint alloc] init];
[endpoint login:username AndPassword:password];
endpoint.delegate = self;

(void)onIncomingCall:(PlivoIncoming*)incoming
{
    // Answer the call
    [incoming answer];
}