> ## Documentation Index
> Fetch the complete documentation index at: https://plivo.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Plivo iOS SDK — Setting Up Push Credentials

> Configure iOS PushKit credentials for incoming call notifications

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:

1. Enable VoIP services in your application.
2. Create a 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 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:

1. Make sure Push Notifications and Background Modes are added.

2. Within Background Modes, enable Audio, AirPlay, and Picture in Picture; Voice over IP; Background Fetch; and Remote Notifications settings.
   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-01.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=65983537647c1826bb35df75eb95edf9" alt="" width="1440" height="821" data-path="images/image-01.jpg" />
   </Frame>

3. On the Info tab, add “App provides Voice over IP services” to the list of Required Background Modes.
   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-02.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=cbf6290ce4c4503f22a6405ad1961e32" alt="" width="1440" height="821" data-path="images/image-02.jpg" />
   </Frame>

## 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](https://developer.apple.com/membercenter). To generate the CSR:

1. Open Keychain access by selecting "Keychain Access" in Utilities folder.
   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-03.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=4650179ed3b3420d770a16a32b8829f7" alt="" width="1440" height="800" data-path="images/image-03.jpg" />
   </Frame>

2. From the "Keychain Access" menu, navigate to **Certificate Assistant** > **Request a Certificate From a Certificate Authority**.
   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-04.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=75e9ee8a1cbbf2af80392037ca87bcc7" alt="" width="1440" height="900" data-path="images/image-04.jpg" />
   </Frame>

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**.
   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-05.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=5045cc3072acd955f442317e5c9bf42c" alt="" width="1440" height="897" data-path="images/image-05.jpg" />
   </Frame>

5. Login to the [Apple Developer Console](https://developer.apple.com/).
   <Frame>
     <img src="https://mintcdn.com/plivo/EvRfP72Bjs4tuRt5/images/certificates-option.png?fit=max&auto=format&n=EvRfP72Bjs4tuRt5&q=85&s=4c620ea46d0fbda6ca07b11142da78e9" alt="" width="1440" height="797" data-path="images/certificates-option.png" />
   </Frame>

6. Navigate to [Certificates, Identifiers & Profiles](https://developer.apple.com/account/resources/certificates/list) page and click '+' to add a new certificate.
   <Frame>
     <img src="https://mintcdn.com/plivo/EvRfP72Bjs4tuRt5/images/certificates-list.png?fit=max&auto=format&n=EvRfP72Bjs4tuRt5&q=85&s=aece4711fa8b1a0632cf9b56ee610a28" alt="" width="1440" height="797" data-path="images/certificates-list.png" />
   </Frame>

7. In the certificate type, select 'VoIP Services Certificate', and then click 'Continue'.
   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-06.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=01abddbd2f822976145a291efacc1f3c" alt="" width="1440" height="1025" data-path="images/image-06.jpg" />
   </Frame>

8. Click 'Continue' to proceed.

9. From the App ID list, select the App ID associated with your app.
   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-07.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=b391acd02146f6f1c93e1a82546d80ab" alt="" width="1440" height="784" data-path="images/image-07.jpg" />
   </Frame>

10. To select and upload the CSR file generated from Keychain, click 'Choose'.
    <Frame>
      <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-08.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=d651e481d072e38ac09dfdf95b2f0091" alt="" width="1440" height="805" data-path="images/image-08.jpg" />
    </Frame>

11. To download and save the VoIP certificate, click 'Download'.
    <Frame>
      <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-09.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=4606f3878c6a6331244fb35fdf565d4c" alt="" width="1440" height="758" data-path="images/image-09.jpg" />
    </Frame>

## 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](https://developer.apple.com/account/ios/profile/).

2. Click “+” to add a new Provisioning Profile.

### To set up a provisioning profile for a sandbox environment

1. Select iOS App Development as the provisioning profile type.
   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-10.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=f95a925e58f59fe54e1cd9647d1d086d" alt="" width="1440" height="817" data-path="images/image-10.jpg" />
   </Frame>

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.
   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-11.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=c33590ac2f5cefae42ea68604403db70" alt="" width="1440" height="806" data-path="images/image-11.jpg" />
   </Frame>

### To set up a provisioning profile for a production environment

1. 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.
   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-12.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=63ba09d3afa1f583554bbdc8166259bb" alt="" width="1440" height="835" data-path="images/image-12.jpg" />
   </Frame>

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.

   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-13.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=1f1298833df9fc565634883231b51969" alt="" width="1440" height="806" data-path="images/image-13.jpg" />
   </Frame>

   <Note>
     **Note:**

     The file is downloaded with a .mobileprovision extension.
   </Note>

## 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.
   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-14.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=f1042420e6f116b001a2edc03752c00b" alt="" width="1440" height="897" data-path="images/image-14.jpg" />
   </Frame>

2. Enter a unique name for the certificate, then click Save.
   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-15.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=de633c0466edf8fcb15062b40b90770d" alt="" width="1440" height="897" data-path="images/image-15.jpg" />
   </Frame>

<Note>
  **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.
</Note>

<Frame>
  <img src="https://mintcdn.com/plivo/_fSpYHZS4fGpqS0Z/images/image_33.png?fit=max&auto=format&n=_fSpYHZS4fGpqS0Z&q=85&s=6b5e3b32ee74ef0077acf0720a41c54a" alt="" width="109" height="97" data-path="images/image_33.png" />
</Frame>

## 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:

```shell theme={null}
openssl pkcs12 -in VOIP_SNS.p12 -nokeys -out cert.pem -nodes
```

### 2. Create a private key

Generate the private key by running:

```shell theme={null}
openssl pkcs12 -in Certificates.p12 -nocerts -out key.pem -nodes
```

Then, to process the RSA key, run:

```shell theme={null}
openssl rsa -in key.pem -out key.pem
```

The RSA key and certificate will be generated.

### 3. Updating the information on the Plivo console

<Note>
  **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.
</Note>

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. In the Plivo console, go to Voice > [Push Credentials](https://cx.plivo.com/home) and paste the text from the respective files in the Certificate and Private Key boxes.

   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-16.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=12387bc843ac6c560e28e13e4033efaf" alt="" width="1440" height="716" data-path="images/image-16.jpg" />
   </Frame>

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

4. Click **Create Credential** to update the changes.
   <Frame>
     <img src="https://mintcdn.com/plivo/2TJ0wsMl3kmSwJSX/images/image-17.jpg?fit=max&auto=format&n=2TJ0wsMl3kmSwJSX&q=85&s=59cdc26c9ab8e548a08be40fddaa8ea6" alt="" width="1440" height="716" data-path="images/image-17.jpg" />
   </Frame>
