Plivo iOS SDK — Setting Up Push Credentials
This document explains how to get the credentials you need in order to receive incoming calls on the Plivo iOS SDK using PushKit. To receive an incoming call, you must:
- Enable VoIP services in your application.
- Create a VoIP Service Certificate.
- Create a provisioning profile for your app.
- Create a push credential (.p12 file) using the VoIP certificate.
- Update the information on the Plivo console.
Let’s see how to accomplish each of these steps.
Enable VoIP services in your application
To enable VoIP services from Xcode, select the Capabilities tab, then:
-
Make sure Push Notifications and Background Modes are added.
-
Within Background Modes, enable Audio, AirPlay, and Picture in Picture; Voice over IP; Background Fetch; and Remote Notifications settings.
-
On the Info tab, add “App provides Voice over IP services” to the list of Required Background Modes.
Create a VoIP Service Certificate
To create a VoIP Service Certificate, create a certificate signing request (CSR), then 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:
-
Open Keychain access by selecting “Keychain Access” in Utilities folder.
-
From the “Keychain Access” menu, navigate to Certificate Assistant > Request a Certificate From a Certificate Authority.
-
Enter a descriptive name for your CSR. For example, iosplivoapp.certSigningRequest.
-
Choose the location to save it on your hard drive, and then click Save.
-
Login to the Apple Developer Console.
-
Navigate to Certificates, Identifiers & Profiles page and click ’+’ to add a new certificate.
-
In the certificate type, select ‘VoIP Services Certificate’, and then click ‘Continue’.
-
Click ‘Continue’ to proceed.
-
From the App ID list, select the App ID associated with your app.
-
To select and upload the CSR file generated from Keychain, click ‘Choose’.
-
To download and save the VoIP certificate, click ‘Download’.
Create a provisioning profile for your app
To create a provisioning profile for your app:
-
Navigate to the Provisioning Profiles section on Apple Developer Portal.
-
Click “+” to add a new Provisioning Profile.
To set up a provisioning profile for a sandbox environment
-
Select iOS App Development as the provisioning profile type.
-
Click Continue.
-
Select your App ID.
-
Select the developer certificates you’d like to include in this provisioning profile.
-
Select the developer devices you’d like to include in this provisioning profile.
-
Enter a name for the provisioning profile.
-
Click Download to download and save the generated profile.
To set up a provisioning profile for a production environment
-
If you intend to submit your app to the app store, select App Store under Distribution for the production environment. Otherwise, select the Ad Hoc distribution type.
-
Click Continue.
-
Select your App ID.
-
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.
-
Enter a name the provisioning profile.
-
Click Download to download and save the generated profile.
Note:
The file is downloaded with a .mobileprovision extension.
Create a push credential with your VoIP Service Certificate
To create push credentials with your VoIP Service Certificate:
-
Export your VoIP Service Certificate as a .p12 file from Keychain Access.
-
Enter a unique name for the certificate, then click Save.
Note:
You need not enter a password to create the .p12 file. Click OK if you’re prompted to enter a password to protect the exported item. The app private key will get stored in .p12 format.
Update the information on the Plivo console
The certificate key and the private key need to be generated from the .p12 file. To generate the files:
1. Create a certificate key
In a terminal window, generate the certificate key by running:
2. Create a private key
Generate the private key by running:
Then, to process the RSA key, run:
The RSA key and certificate will be generated.
3. Updating the information on the Plivo console
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. If you delete the production certificate, you’ll stop receiving incoming calls by all live apps.
-
From the certificate file, strip anything outside of —–BEGIN CERTIFICATE—– and —–END CERTIFICATE—– boundaries.
-
From the key file, strip anything outside of —–BEGIN RSA PRIVATE KEY—– and —–END RSA PRIVATE KEY—– boundaries.
-
In the Plivo console, go to Voice > Push Credentials and paste the text from the respective files in the Certificate and Private Key boxes.
Based on the types of profile and certificate generated from Apple Developer console, choose either Production or Sandbox environment.
-
Click Create Credential to update the changes.