Updating push services certificate in heroku

Well, it was a year ago that I updated my app Grabble Words to use Parse Server (for storing data in the cloud) via herokuapp (for running applications in the cloud) and mongodb (database hosting service). Here‘s where I delved into some difficulties with push notifications at the time.

I’ve just received a notification from Apple reminding me that their production push services certificates only last for a year, meaning that there’s a little annual maintenance to do to keep notifications popping up on people’s devices. Otherwise how are people going to know that the other player has had their move!?

Making this update isn’t that big a job, but it can be hard to get your head back into these sorts of things. This could be a good time to record the process here…before i forget!

Basically two things need to be done:

  1. Create a new push services certificate in Apple’s member center (aka Certificates Identifiers and Profiles). What we need out of this step is a p12 file.
  2. Replace your app’s push services certificate in heroku with your new p12 file.

Fleshing these steps out a little:

Creating a new push services certificate

  1. Open Certificates, Identifiers and Profiles.
  2. Find your app in the App IDs section and select Edit.
  3. Find your app’s push services certificate that is expiring. Below it select Create Certificate.
  4. You will find instructions appear for requesting the certificate in your keychain. Follow these instructions!
  5. Once you have the request, you can upload this back in the Certificates Identifiers and Profiles page.
  6. You should now have a certificate. Download this certificate, which should be a cer file.
  7. Double click on the cer file which will install the key into your keychain.
  8. Finally, from the Certificates section of your keychain, export this cer file, and you should have a p12 file. Hooray!

Replacing your app’s push certificate file in heroku

    1. Find the local folder for your app’s heroku file system heroku. 

If you haven’t cloned this, or perhaps you’re on a different computer from when you cloned it originally, you’ll need to find the folder that you cloned locally when you first generated a heroku app.   (If you don’t have one, check here how to do this.

    1. From the heroku folder for your app in Terminal, log into heroku. (hopefully you still have your password!)
heroku login
    1. Find your production push services certificate locally and replace it just in Finder with the p12 file you downloaded earlier.
    2. Back in Terminal, upload the updated p12 file using git. Uploading in git is called ‘pushing’, so I guess we’re pushing the push certificate…
git add .
git commit -am "replaced push services certificate"
git push heroku master

That’s it! Grabble Words should now have its push services certificate safely updated in the cloud, and we have another year of game notifications, hooray!

iOS development with Swift - book: https://manning.com/books/ios-development-with-swift video course: https://www.manning.com/livevideo/ios-development-with-swift-lv

Tagged with:
Posted in Swift

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: