To enable push notifications in your game or app, it needs to be properly "signed" with a provisioning profile that is configured for push notifications. In addition, our servers need a matching SSL certificate to communicate with Apple's servers.
The provisioning profile and SSL certificate are closely tied together and are only valid for a single App ID. This is a protection that ensures that instances of your games or apps only receive push notifications from you, and no one else. It's important to note that apps use different provisioning profiles for development and distribution. There are also two types of push server certificates:
- Development - If your app is running in Debug mode and is signed with the Development provisioning profile (when Code Signing type is “Development”), then our server must be using the "Apple Push Notification service SSL (Sandbox)".
- Production - Apps that are distributed as Ad Hoc or on the App Store (when Code Signing type is “Distribution”) our servers must use "Apple Push Notification service SSL (Production)".
- NOTE: If there is a mismatch between these, push notifications cannot be delivered to your app.
Warning: Do not submit to the App Store using a Development certificate. Development apps use different tokens that, when included in a push to a production app, will fail and in many cases cause all other pushes to fail.
We recommend that you create both certificates and upload them to our servers so you only have to do these steps once, but if you prefer, you can just use the Development Certificate until you are ready to submit to Apple. Also, the Certificate Signing Request (CSR) (described below) can be used for both Development and Production, so keep it handy in the case you need to renew certificates or generate new ones.
To start, log into your Apple Development account (https://developer.apple.com/account) and click on "Identifiers".
This will show your Apple IDs (or the profiles you've already created).
Click on the App ID you want to add Push Notifications to (or click on the "+" symbol to add a new App ID)
then click the "Settings" button at the bottom.
At the bottom will be the settings for Push Notifications.
Click the Check Box to enable Push Notifications, and then click the "Create Certificate" button (within Development)
Next you'll be presented with some steps to perform on your Macintosh
After completing these steps on your Macintosh, click Continue, and upload the CertificateSigningRequest you created.
Note: Do the same for Production while you're here (using the same CertificateSigningRequest)
Once this complete you will need to download your SSL Certificate and import it into your KeyChain.
Each certificate is valid for 1 year, so be sure to come back and renew it BEFORE the expiration date to ensure you
have no downtime in your App.
Each will have a specific name ("aps_development.cer" and "aps_production.cer") as to be clear which is which.
Once you have downloaded the SSL Certificates, you can dbl-click on them to import them into your Keychain.
In your Keychain, ctrl-click (or R-Click) on the certificates and Export them. You will be asked to save them as
.p12 files which is exactly what we need.
Add a password to your .p12 files or they will not contain your private key necessary for Apples authentication.
Note: The password you assign is only used to protect the .p12 file and can be anything (but don't forget it,
otherwise you'll need to re-export it from Keychain).
Now log into the Apmetrix Dashboard (https://www.apmetrix.com/login/) and upload them to our servers by selecting
the Tasks->Administration->Accounts then click on your Application. Switch to the Task tab and add the
Apple Push/Google Cloud Messaging connector.
In this Connector add your .p12 password, and upload your .p12 files accordingly.
Now that you've added Push Notifications to your App, you will need an updated Provisioning Profile. Yes... Apple should have added it to your existing profile already (and it will show that they have), but Apple has a bug which does not actually SET Push Notification in the Profile... no matter how many times you add push and download it, again and again...
We recommend that you create a new Provisioning Profile, add your app to it, download it, double click on it, then update x code to use it and you should be fine.
If you are getting a "aps-environment" compile error... create a new Provisioning Profile.
If you are making a Native iOS App read: iOS Native Push Notification Code Example
If you are making an Unity iOS App read: Unity iOS Native Push Notification Code Example