Right way to generate production environment enabled APNS certificate

My app is enabled to receive push notifications. I have followed the steps outlined in iOS App Distribution guide to generate a "Universal Push Notification Client SSL Certificate" (selected “Apple Push Notification service SSL (Sandbox & Production)”) and install a Client SSL Signing Identity on my server. Every time when I start my app, it registers with APNS to receive remote notifications and sends the device token to my server. My server uses notnoop/java-apns to send push notifications. All works fine and my app running on iPhone (device registered using its UDID) receives push notifications when I run the app from XCode.



Now I want to submit my app to the app store. I generated the archive using XCode and uploaded to iTunes by selecting my "App store distribution profile" which has the entitlement "aps-environment" set to "production". I want to test this app build using TestFlight before submitting for review. I installed the app using TestFlight on the same iPhone. When I run the app on the same iPhone, it does not receive any push notifications. My server encounters an error (bad token, errorcode : 8) after sending push notifications!

So my questions are :

a) Why does my server get this error even though it uses a certificate which was enabled for both sandbox and production environments?

b) What is the right way to generate APNS certificate which can work well in production environment?



Any pointers would be greatly appreciated!

Accepted Answer

I removed my device from the registered devices list and uploaded another archive. With this change, I am able to get push notifications!

Hi Aakash, thanks for posting this, I am using Appcelerator to build my apps, and have the same issue. Entitlements set to Production and I can see on the logs on my iphone that it is connecting and receiving the device token.


Similarly on Appcelerator Push Service I can see the device, and the Push says successfully delivered.


However, the device shows nothing 😟


Please can you give more detail on what you meant by 'I removed my device from the registered devices list' please.


Where would I find this list?

Hi Aakash,


Am I understand you correctly that you was able to generate only one apns certificate and use it for production and debug mode? If yes, how you maneged to do so? Because even in apple docs after they generated a universal certificate they still show only one active apns setting in app (https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html) "In your developer account, the status of the Push Notifications service for the specified environment (Development or Distribution) changes from

Configurable
to
Enabled
." I dont understand why they say "Development OR Distribution" if it is a universal certificate.
Right way to generate production environment enabled APNS certificate
 
 
Q