apple push notifications - no valid 'aps-envir

2019-06-16 01:34发布

问题:

I'm tearing my hair out trying to get push notifications to work! I'm following this tutorial 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.

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) ???

As far as I can tell, all of this is ok:

  1. My ssl certificate + key talk nicely to the apple server (ignore the error, I still get a prompt eventually):

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 .....

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:

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}

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 :(

The only things I can think of:

  • 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.
  • Code is still getting signed with the Team Profile instead of my new one? Is there a way to ensure this?

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?

回答1:

You know what it was? My app id.

foo.bar is treated as foo.bar.* (which is not permitted)

you have to have foo.bar.xxx



回答2:

I think for push you need an Entitlements.plist file that has an aps-environment key, with a value of "production". I just got finished getting this working (again) for my app. Some other answers here helped me get the Organizer window to pop up after I did the Archive, but then I was getting your error.

I also had to quit & restart XCode with some frequency, touch settings that didn't actually change, delete the old, pre-push certificate and add the new one, etc etc. A lot of the settings in XCode didn't actually change, but it seems like touching them caused it to start working.