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!