/plivo-ios-sdk2-examples

Examples for the IOS SDK version 2

Primary LanguageObjective-C

Plivo Voice Quickstart for iOS

plivo-iOSsdk-2.0-example

The Plivo iOS SDK v2 allows you to make outgoing and receive incoming calls in your iOS application.

Supports Pushkit and Callkit. Eliminates the need for persistent connections to recieve incoming calls.

Compatible with iOS version 8 and above.

Plivo iOS SDK now supports IPv6 networks. Users can make and receive calls when their device is connected to a network that uses IPv4, IPv6, or both versions of the protocol.

To get started with the quickstart application follow these steps. Steps 1-3 will enable the application to make a call. The remaining steps 4-5 will enable the application to receive incoming calls in the form of push notifications using Apple’s VoIP Service.

  1. Install the PlivoVoiceKit framework using Cocoapods

  2. Create Endpoints

  3. Run the app

  4. Plivo iOS SDK V2 with Push Kit integration

  5. Receive an incoming call

1. Install the PlivoVoiceKit framework using Cocoapods

It's easy to install the Voice framework if you manage your dependencies using Cocoapods. Simply add the following to your Podfile:

pod 'PlivoVoiceKit'

SDK Reference - More documentation related to the Voice iOS SDK

2. Create Endpoints

Signup and create endpoints with Plivo using below link

Plivo Dashboard

3. Run the app

Open SwiftVoiceCallingApp.xcworkspace.

Build and run the app.

Enter sip endpoint username and password.

After successful login make VoiceCalls.

4. Plivo iOS SDK V2 with Push Kit integration

To enable Pushkit Integration in the SDK, please refer to below link on Generating VoIP Certificate.

Generating VoIP Certificate

5. Receive an incoming call

// MARK: PKPushRegistryDelegate
func pushRegistry(_ registry: PKPushRegistry, didUpdate credentials: PKPushCredentials, forType type: PKPushType) {
            
    if credentials.token.count == 0 {
        print("VOIP token NULL")
        return
    }
    
    // This method is used to register the device token for VOIP push notifications.
    endpoint.registerToken(credentials.token)
}

//When the push arrives below delegate method will be called. 
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, forType type: PKPushType) {
            
    if (type == PKPushType.voIP) {
        
        DispatchQueue.main.async(execute: {() -> Void in
            endpoint.relayVoipPushNotification(payload.dictionaryPayload)
        })
    }
}

PushInfo is the NSDictionary object forwarded by the apple push notification. This will enable the application to receive incoming calls even the app is not in foreground.

You are now ready to receive incoming calls.

plivo-iOSsdk-2.0-example

License

MIT