In this guide, we'll go through all the necessary steps to get your Apple push credentials configured for Twilio Notifications. The end result is a Twilio Credential which you can then use to receive notifications in your iOS app. Let's get started!
These are the steps you'll take:
Log into your Apple development account and click on Identifiers under the Certificates, Identifiers & Profiles section. This will show a list of identifiers, including App IDs.
If your App ID is already on this list, click on it, and a list of capabilities will pop up.
If your App ID isn't on this list, click the + symbol to add a new App ID.
com.twilio.notify.NotifyQuickstart
) of your app in Xcode.Now you'll need to create a push notification certificate. This will enable your app to receive notifications. You can either make a development certificate or a production certificate. For this guide, we'll make a development certificate. We recommend you use Xcode managed certificate.
In your Xcode project, go to the General pane of the target for your iOS application:
In the Signing section, check Automatically manage signing:
If you are using the Quickstart app and see a provisioning error message, you may need to rename the bundle ID to a unique identifier:
To do so, go to https://developer.apple.com/account/resources/certificates/list and give the bundle a new name. Then, enter your new identifier in the Identity section of the General pane:
Go to the Capabilities tab and make sure that Push Notifications are enabled:
You can verify that your certificates have been created in a few different ways. For more information on Apple Certificates, click this link.
Via the Apple developer portal:
Make sure your certificate is stored in your keychain:
iPhone
to filter for iPhone certificates.Congratulations! You just created an Apple Development iOS Push Services certificate. If you run into problems during this process, please see this guide from Apple.
While we recommend you use Xcode managed certificates for your application, you may prefer to create your certificate manually.
Well done! You just created an Apple Development iOS Push Services certificate. Now you can download it and double-click on it to add it to your Mac's keychain.
On your Mac, open Applications > Utilities > Keychain Access, and go to the My Certificates Category at the top.
Apple Development iOS Push Services
.cred.p12
— make sure you leave the password blank.This is your credential file. You will extract your certificate key and private key from this file — you need these two keys to create a Twilio credential. First, run this command in Terminal:
openssl pkcs12 -in cred.p12 -nokeys -out cert.pem -nodes
cert.pem
is your certificate key file. Now run the following command in Terminal:
openssl pkcs12 -in cred.p12 -nocerts -out key.pem -nodes
key.pem
is your private key file. Now run this command to process this key:
openssl rsa -in key.pem -out key.pem
You can now paste your credentials into the modal found in the Twilio Console to upload them.
Make sure that you strip anything outside of the -----BEGIN CERTIFICATE-----
and -----END CERTIFICATE-----
boundaries and outside of the -----BEGIN RSA PRIVATE KEY-----
and -----END RSA PRIVATE KEY-----
boundaries before pasting your credentials. Check the Sandbox button if you made a development certificate. Sandbox is synonymous with development mode:
Once a Credential is saved, CERTIFICATE
and PRIVATE KEY
fields will be hidden for security reasons.
After you've pasted them in, click Save. If everything went well, you'll see an SID appear on the new page. Copy it to your clipboard — you will need it in the next step.
Congratulations, you just made a Twilio Push Credential!
Twilio allows you to build multiple applications within a single account. To separate those applications, you need to create Service instances that hold all the data and configuration for a given application.
Specifically, you need to configure your Service instance to use the Credential that contains your APNS certificate and private key. You can do that using the Services page in the Console. You'll need to update your Service with the Twilio Push Credential SID:
If you are just getting started, set up this APN credential first, then create your Service by clicking the blue plus button on the Services Console page.
You are ready to go. You can now check out the iOS Quickstart to start sending notifications.