title: iOS Push Notifications work for Dev but not Enterprise Distribution
body: <p>I have read many posts here and been through the Apple docs all day.  None of the posts here have answers and the docs  are unclear on this issue.</p>
  
  <p>We have an app that is receiving push notifications when using the Dev profile but not when we use our Enterprise distribution profile.</p>
  
  <p>The app ID is enabled for push notifications in sandbox.</p>
  
  <p>The cert and both profiles are associated with the app id.</p>
  
  <p>If I build form Xcode push notifications come in fine.  If I archive and distribute the server returns:</p>
  
  <pre><code>[Failed to push 6dje7djksis7hyhdjshsjksjd74jdjskshdjd8dhjjdkwu for reason 8]
  </code></pre>
  
  <p>Which is Invalid Token.</p>
  
  <p>One thing I noticed was that our dev provisioning profile has the following for aps-environment:</p>
  
  <pre><code>&lt;key&gt;aps-environment&lt;/key&gt;
  &lt;string&gt;development&lt;/string&gt;
  </code></pre>
  
  <p>While the Enterprise distribution profile has:</p>
  
  <pre><code>&lt;key&gt;aps-environment&lt;/key&gt;
  &lt;string&gt;production&lt;/string&gt;
  </code></pre>
  
  <p>When I run a debug build to my phone (push works) the .app file's entitlements are:</p>
  
  <pre><code>&lt;key&gt;aps-environment&lt;/key&gt;
  &lt;string&gt;development&lt;/string&gt;
  </code></pre>
  
  <p>When I archive they are always (no matter what provisioning profile I use or scheme):</p>
  
  <pre><code>&lt;key&gt;aps-environment&lt;/key&gt;
  &lt;string&gt;production&lt;/string&gt;
  </code></pre>
  
  <p>Can anyone tell me if this is expected?  None of the other questions on this site that I have been able to find actually come up with a reason why Dev would work but Enterprise Distribution would not.</p>
  
  <p><em>Why would archiving <strong>always</strong> make the aps-environment production?</em></p>
  
  <p>Thanks for your time.</p>
  
  <p><strong>Update</strong>
  This is interesting.</p>
  
  <p>From: </p>
  
  <p><a href="http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ProvisioningDevelopment/ProvisioningDevelopment.html">http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ProvisioningDevelopment/ProvisioningDevelopment.html</a></p>
  
  <p>"You must get separate certificates for the sandbox (development) environment and the production environment. The certificates are associated with an identifier of the application that is the recipient of push notifications; this identifier includes the application’s bundle ID. When you create a provisioning profile for one of the environments, the requisite entitlements are automatically added to the profile, including the entitlement specific to push notifications, . <strong>The two provisioning profiles are called Development and Distribution. The Distribution provisioning profile is a requirement for submitting your application to the App Store."</strong></p>
  
  <p>This could mean that you don't use a distribution profile unless you are going to production.  Is that true?  That seems weird since you can make an enterprise distribution profile before going to the app store.</p>
  
  <p>Anyone have an idea about that?  I can't find any specific information in the docs about that.</p>
  
  <p>Thanks</p>