title: apple push notifications - no valid 'aps-environment' have tried all solutions I've seen on web?
body: <p>I'm tearing my hair out trying to get push notifications to work! I'm following <a href="http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12" rel="noreferrer">this tutorial</a> to basically no avail. I've deleted xcode several times, redone the whole apple dev certificate, cleaned out my login keychain a few times. This has helped a few issues, but at the end I'm still stuck.</p>
  
  <p>What I think I need to do (from reading other people's experience with this):
  1) My openssl cert and key need to be talk to the apple server
  2) The app id with this openssl cert has a provisioning profile associated with it.
  3) The build (in xcode) needs to have the proper provisioning profile associated with it
  4) The build identifier (in xcode) needs to have the same text as the application id with the provisioning profile
  4) ???</p>
  
  <p>As far as I can tell, all of this is ok:</p>
  
  <ol>
  <li>My ssl certificate + key talk nicely to the apple server (ignore the error, I still get a prompt eventually):</li>
  </ol>
  
  <blockquote>
    <p>MacBook-Pro:apple_dev_certification nflacco$ openssl s_client -connect
    gateway.sandbox.push.apple.com:2195 -key xxx.pem -cert xxx.pem  Enter
    pass phrase for xxx.pem: CONNECTED(00000003) depth=1 /C=US/O=Entrust,
    Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009
    Entrust, Inc./CN=Entrust Certification Authority - L1C verify
    error:num=20:unable to get local issuer certificate .....</p>
  </blockquote>
  
  <p>2,3,4) When I create a new project, it never gets the right app ip (build settings->info-bundle identifier). If my provisioning profile matches 'com.xxx' then the app will always be 'com.xxx.FOO', so the default IOS Team Provisioning Profile is selected. I run the app like that, and get: </p>
  
  <blockquote>
    <p>2011-10-22 22:42:45.086 VVV[3552:707] Failed to get token, error:
    Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment'
    entitlement string found for application" UserInfo=0x16d140
    {NSLocalizedDescription=no valid 'aps-environment' entitlement string
    found for application}</p>
  </blockquote>
  
  <p>4 contd) I want to use my provisioning profile that uses my app id with push enabled, so I change the app identifier to 'com.xxx', and select the proper profile in the code signing option in the build menu. Install it on my iPhone, same thing :(</p>
  
  <p>The only things I can think of:</p>
  
  <ul>
  <li>My provisioning profile is not correct? I've made a new one several
  times, deleted the all existing ones in xcode organizer, but this
  hasn't helped.</li>
  <li>Code is still getting signed with the Team Profile instead of my new
  one? Is there a way to ensure this?</li>
  </ul>
  
  <p>Any ideas on what I should do here? This can't be this complicated. Should I just wipe my HD and reinstall from scratch and hope it works?</p>