Search code examples
ioskeychainapn

Messy Keys & iOS notification problems


a little background info of what I'm doing. Im an amateur iOS programmer. I just joined this relatively new startup company and was assigned a task to replicate a new app from another old application with minor changes, mainly images & content. Everything is working fine except for the notification , and i did some findings regarding how APN works (first time touching APN stuff ) and started to create certSignRequest & p12 file according to online tutorials (raywenderlich and few more). Apparently I created too many keys for testing & exploring, all of it are not working and kinda messed up the Keychain Access

https://i.sstatic.net/pt55D.jpg

The backend code was written in node js. I've placed the p12 file into the corresponding folder and added codes in the backend. It seems the apn acknowledge my device token and delivered according to the console.

https://i.sstatic.net/2wOWD.jpg

Im suspecting that I might messed up during the creating certSignRequest/p12 part but im not sure.

  1. How do I identify which key is useful and which are not ? is there anyway to tidy up the whole thing ?

  2. after uploading the certSignRequest to Production SSL Cert, it allows me to download aps_production.cer, what is the usage of this cert ?

Please advise me. Thanks in advance !

p/s : there are no documentations or whatsoever, the previous programmer who created the whole thing left and is unable to be contacted anymore.


Solution

  • A couple things to help you on your way:

    1. When you create the CSR it will allow you to choose a common name for your keys. Pick something unique to all those other keys you have in your keychain, that way you can easily identify it.

    2. Create both a development and a production push certificate. You mentioned you created aps_production.cer. Download these and put it in your keychain.

    3. You can verify if you 'messed up on the certSignRequest/p12 part' by following the Ray Wenderlich tutorial that you mentioned here: http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1

    Go through the steps starting at 'making a PEM file' and go all the way through the end of the tutorial. Take the time to actually do it, it won't take too long. It will give you a quick PHP script and a way to test the assets you just created using the Mac terminal and send a push to the test app. If you get this working, then you can more confidently add the p12 file to the backend knowing that it works.

    1. You can delete any keys from your keychain where you are confident that they were created out of your experimentation. If you're unsure, I would leave them be until you can figure out what they're for.