title: APNS Push Notifications headache; works for development but not production
body: <p>Hi friends
  I have been at this for atleast a week. For the life of me i coul'dnt get push notifications working on production, works fine in development.</p>
  
  <p>I have tried, any and every solution that i could find online, nothing worked.</p>
  
  <p>I have regenerated the certificates atleast a 100 times</p>
  
  <p>My entitlements.plist file is good  - </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
  &lt;dict&gt;
      &lt;key&gt;get-task-allow&lt;/key&gt;
      &lt;false/&gt;
      &lt;key&gt;aps-environment&lt;/key&gt;
      &lt;string&gt;production&lt;/string&gt;
      &lt;key&gt;application-identifier&lt;/key&gt;
      &lt;string&gt;$(AppIdentifierPrefix)$(CFBundleIdentifier)&lt;/string&gt;
      &lt;key&gt;keychain-access-groups&lt;/key&gt;
      &lt;array&gt;
          &lt;string&gt;$(AppIdentifierPrefix)$(CFBundleIdentifier)&lt;/string&gt;
      &lt;/array&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p>Ofcoures when i change the environment and get-task-allow to true, it works fine with gateway.sandbox.push.apple.com. I have also tried with exact bundle name rather than "$(AppIdentifierPrefix)$(CFBundleIdentifier)"</p>
  
  <p>But when i change aps-environment to production and get-task-allow to false(even tried with true) - the device does not recieve any notifications.</p>
  
  <p>i have tried using pushmebaby, writing my ownscript, easyapns - all work with development. 
  I just cant figure out why it breaks in production.</p>
  
  <p>My build settings are good, i have created a duplicate of release configuration, called it ad-hoc and set the codesigning elements to entitlements.plist and the identity to the respective profile.</p>
  
  <p>I am using the same method to generate the certificate files as i have used for generating the developer certificate</p>
  
  <pre><code>openssl pkcs12 -in aps-production-cert.p12 -out aps-production-cert.pem -nodes
  </code></pre>
  
  <p>When i use codesign -dvvvv --entitlements -Forecast.app i get this - which looks fine.</p>
  
  <pre><code>Executable=/Users/seantan/Documents/Alpha/build/Ad-Hoc-iphoneos/Forecast.app/Forecast
  Identifier=com.xxxxxxxx.wforecast
  Format=bundle with Mach-O universal (armv6 armv7)
  CodeDirectory v=20100 size=2651 flags=0x0(none) hashes=124+5 location=embedded
  CDHash=63a3d238db30f8e4fd3c2a545867fe2fe645a981
  Signature size=4313
  Authority=iPhone Distribution: xxxxxxxx
  Authority=Apple Worldwide Developer Relations Certification Authority
  Authority=Apple Root CA
  Signed Time=Dec 24, 2010 2:24:08 PM
  Info.plist entries=25
  Sealed Resources rules=3 files=200
  Internal requirements count=1 size=216
  ??qq?&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
  &lt;dict&gt;
      &lt;key&gt;application-identifier&lt;/key&gt;
      &lt;string&gt;SYK86VV33F.com.xxxxxx.wforecast&lt;/string&gt;
      &lt;key&gt;aps-environment&lt;/key&gt;
      &lt;string&gt;production&lt;/string&gt;
      &lt;key&gt;get-task-allow&lt;/key&gt;
      &lt;true/&gt;
      &lt;key&gt;keychain-access-groups&lt;/key&gt;
      &lt;array&gt;
          &lt;string&gt;SYK86VV33F.*&lt;/string&gt;
      &lt;/array&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p>I am totally out of ideas/solutions. Anybody can point me to the right direction?</p>
  
  <p>Before someone suggests, i have tried with gateway.push.apple.com for production and gatetway.sandbox.push.apple.com for development</p>