Plivo iOS SDK V2 - Setting up Push Credentials

The following section explains on how to receive incoming calls on the Plivo iOS SDK v2 using pushkit. To receiving an incoming call, you must:

  1. Enable VoIP services in your application.
  2. Create the VoIP service certificate.
  3. Create a provisioning profile for your app.
  4. Create a push credential (.p12 file) using the VoIP certificate.
  5. Update the information in the Plivo dashboard.

Let us see each of these steps in detail.

1. Enable VoIP services in your application

To enable VoIP services from XCode, select the “Capabilities” tab and enable the following settings:

  1. Make sure “Push Notifications” and “Background Modes” are set to On.
  2. Within “Background Modes”, enable “Audio, AirPlay, and Picture in Picture”, “Background Fetch”, and “Remote Notifications” settings. Remote Notifications

On the “Info” tab, add “App provides Voice over IP services” to list of Required Background Modes. App Provides

2. Create VoIP Service Certificate

To create a VoIP service certificate, you must:

  1. Create a certificate signing request (CSR)
  2. Create the service certificate using the CSR

Create a Certificate Signing Request (CSR)

Certificate signing request (CSR) is a prerequisite for creating a certificate in the iOS Dev Center. To generate the CSR:

  1. Open Keychain access by selecting “Keychain Access” in Utilities folder.
  2. From the “Keychain Access” menu, navigate to Certificate Assistant > Request a Certificate From a Certificate Authority. Keychain Access
  3. Enter a descriptive name for your CSR. For example, iosplivoapp.certSigningRequest.
  4. Choose the location to save it on your hard drive, and then click Save. Certificate Assistant
  5. On the Apple Developer portal, make sure that your App ID has the “Push Notifications” service enabled.
    Visit the Certificates section (production tab) in Apple Developer portal. Save
  6. Click ‘Add Certificate’ to add a new Production certificate.
  7. In the certificate type, select ‘VoIP Services Certificate’, and then click ‘Continue’. Certificates
  8. Click ‘Continue’ to proceed.
  9. From the App ID list, select the App ID associated with your app. VoIP Services Certificate
  10. To select and upload the CSR file generated from Keychain, click ‘Choose’. App ID
  11. To download and save the VoIP certificate, click ‘Download’.

3. Create a provisioning profile for your app

To create a provisioning profile for your app

  1. Navigate to the Provisioning Profiles section on Apple Developer Portal.

  2. Click ‘+’ to add a new Provisioning Profile.

To Set Up Provisioning Profile For Sandbox Environment

  1. Select “iOS App Development” as the provisioning profile type. CSR File

  2. Click “Continue”.

  3. Select your App ID.

  4. Select the developer certificates you’d like to include in this provisioning profile.

  5. Select the developer devices you’d like to include in this provisioning profile.

  6. Enter a name for the provisioning profile.

  7. Click Download to download and save the generated profile.

VoIP certificate

To Set Up Provisioning Profile For Production Environment

  1. If you intend to submit your app to the app store, select “App Store” under Distribution for production environment. Else, select ‘Ad Hoc’ distribution type. iOS App Development

  2. Click “Continue”.

  3. Select your App ID.

  4. Select the iOS distribution certificate you wish to include in this provisioning profile. (This should be the ‘App Store or Ad Hoc’ certificate for your production app.)

  5. Enter a name the provisioning profile.

  6. Click ‘Download’ to download and save the generated profile.

Download

4. Create a Push Credential with your VoIP Service Certificate

Note:

The file is downloaded with .mobileprovision extension.

To create a Push Credential with your VoIP Service Certificate

To create Push Credentials with your VoIP Service Certificate

  1. Export your VoIP Service Certificate as a .p12 file from Keychain Access.
    image alt text

  2. Enter a unique name for the certificate and then click Save.
    image alt text

Note:

You need not enter a password to create the .p12 file. Click OK if you are prompted to enter a password to protect the exported item. The app private key will get stored in `.p12` format.


Ad Hoc

5. Update the information in Plivo dashboard

The certificate key and the private key need to be generated from the .p12 file. To generate the files:

1. Create a Certificate Key

Run the following command in terminal to generate the Certificate key:

openssl pkcs12 -in VOIP_SNS.p12 -nokeys -out cert.pem -nodes

2. Create a Private Key

openssl pkcs12 -in Certificates.p12 -nocerts -out key.pem -nodes

Run the following command to process the RSA key:

openssl rsa -in key.pem -out key.pem ``` The RSA Key and Certificate will be generated.

2. Updating information in Plivo dashboard

  1. From the certificate file, strip anything outside of —–BEGIN CERTIFICATE—– and —–END CERTIFICATE—– boundaries.
  2. From the key file, strip anything outside of —–BEGIN RSA PRIVATE KEY—– and —–END RSA PRIVATE KEY—– boundaries.
  3. Paste this text into the UI available in the Plivo Dashboard.

    Certificate

    Based on the types of profile and certificate generated from Apple Developer console, choose from either Production or Sandbox environment.

  4. Note:

    You can change the environment from sandbox to production, but not from production to sandbox. To change your environment to sandbox from production, delete the certificate and create a new one for sandbox. By deleting the production certificate, you will stop receiving incoming calls by all live apps.

  5. Click Save to update the changes. Save