Search code examples
push-notificationapple-push-notificationsprovisioning-profile

Apple push notification - distribution and development at the same time


Is it possible to get Apple push notification service to work on both development and distribution builds?

I want to debug my app while it's installed on other devices with the distribution provisioning profile.


Solution

  • Yes, you can create push certificates for both the distribution and development (sandbox) push environment. And an individual app installed on a device will choose which push environment to work with based on the <aps-environment> entitlement in the provisioning profile (which will determine if it is assigned a production or development device token when registering to APNS).

    That said, I strongly recommend that you don't use the same server and DB for storing production and development device tokens. Development tokens are valid only in development push environment. If you try to send notifications to development tokens while using the production push certificate and connecting to production APNS server, you'll get an error (invalid token) and the connection will be closed, which may interrupt the sending of notifications to production tokens too.

    If you have a development server, your development build should send the device token to that server, and only the development server should connect to the APNS sandbox environment.