How to fix “no valid 'aps-environment' ent

2019-01-05 08:21发布

I've been trying very very hard to create a simple simple iOS app which can recieve push notifications. My only reason for doing this is to establish a procedure for some other team members to use, and have not been able to find an up to date, working version of such instructions elsewhere on the web. Our shop is fairly new to iOS dev, I personally am completely inexperienced with iOS dev and Xcode. I've stumbled through tens of tutorials, articles, and trouble posts from Apple and elsewhere and I feel like I might be nearly there...

Here is where I've got to (note I'm using Xcode 4.3 and trying initially to deploy just to iOS 5.1, and I gather that some things may have changed recently vs earlier versions of Xcode, but again I'm new to all this -- and finding it completely confusing and convoluted):

1) I've got a provisioning profile on my iPhone which has Push enabled

2) In my test Xcode project I've got that provisioning profile selected as the signing identity (in Build Settings > Code Signing)

enter image description here

3) I've got my bundle identifier under Summary and Info > Custom iOS Target Properties set properly* (I think??)

4) I've got registerForRemoteNotificationTypes being called in my delegate's didFinishLaunchingWithOptions

5) I've got didRegisterForRemoteNotificationsWithDeviceToken and didFailToRegisterForRemoteNotificationsWithError in my delegate, set up to log the device token or error respectively

6) I've got Enable Entitlements checked under Summary.

7) Right below that the Entitlements File selected is Tinker6 (the name of my test project), which was generated automatically when I checked Enable Entitlements

8) In the Tinker6.entitlements file I've got the following (which I've gathered is correct based on several different posts all over the web, but which I can't find anything definitive from Apple itself on):

enter image description here

Updated

9) Also, I have tried the whole thing without an entitlements file, and get essentially the same result.

10) My mobileprovision file contents include entitlements properly (I've scrambled the number and domain but structurally the same):

<key>application-identifier</key>
<string>12355456A7.com.whatever.tinker</string>
<key>aps-environment</key>
<string>development</string>
<key>get-task-allow</key>
<true/>
<key>keychain-access-groups</key>
<array>
    <string>12355456A7.*</string>
</array>

/end update

When I attempt to run this on my device, I get the following error in Xcode output:

2012-06-11 12:45:23.762 Tinker6[13332:707] Failed to get token, error: 
Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' 
entitlement string found for application" UserInfo=0x24a3b0 
{NSLocalizedDescription=no valid 'aps-environment' entitlement string 
found for application}

I've tried setting get-task-allow to NO, aps-environment to production, all four possible combinations, same thing.

How can I get past this? Where is definitive documentation on this?

-- further background follows --

*As far as the bundle id, I am still not clear on how this should be set in relation to App Ids and Profile ids in the Provisioning profile. In the Provisioning portal under App Ids I have this (again, scrambled the number and domain):

enter image description here

And the two places bundle id is set I have this:

enter image description here enter image description here

I am not at all sure these are correct or whether one or both should be set to 12355456A7.com.whatever.tinker, though I've tried those earlier in the process with no success...

Note I realize there are many posts with similar titles, however they all seem to be out of date based on the file names and so-forth given, and the fact none of the solutions seem to be useful. I'm hoping the greater level of detail I've given will warrant a quality response. I will probably assign a bounty as soon as possible and if you give a high quality answer that leads to a solution I will award you the bounty as well as promote your answer via twitter and my blog. Especially if you crosspost post a really good "here are the exact 500 steps you need to get a simple push notification app working including provisioning and whatever else" article on your blog or whatever.

23条回答
乱世女痞
2楼-- · 2019-01-05 08:58

(Xcode 5) Well, after spending an hour I solved my issue. Even if you re-generate the provisioning file in Xcode 5, you should manually update your account. I only changed provisioning file in the Organizer tab that did not work, Xcode kept build with old provisioning file.

So go to

Xcode > Preferences > Accounts > View Details (Select your account)

Then refresh your provisioning files.

查看更多
趁早两清
3楼-- · 2019-01-05 08:59

XCode 6.1.1, and multiple apple developer accounts

Another answer for this already fairly comprehensive mix: I came across this issue again today, and this time it was due to my having multiple apple accounts. I needed to first add the 2nd developer account in XCode > Preferences > Accounts > +

Ensure that the Push Notification Capability is ON

Next I needed to actually explicitly enable In-App Purchase in the app (I did not need to do this previously). XCode > (the app window) > Targets > Capabilities > In-App Purchase ON (and at this stage I was given the option to choose the correct certificate)

Note that I had already added the Push enabled certificate by double clicking it in Finder.

enter image description here

查看更多
三岁会撩人
4楼-- · 2019-01-05 08:59

I had the same issue was everyone else and tried all the above tricks, nothing worked. I even deleted and started fresh with a different developer account.

What worked for me in the end was

  1. Do as suggested above and create APP ID
  2. Then create provisioning profile
  3. DO NOT use the team wildcard profile (managed by xcode one) in the development section of the provisioning. You need to make a separate one using that app ID that you've made push notification active for. This way when you develop it will have the push notification function built in.

I don't know if you can enable that for a wildcard app, but after trying at least 12 different suggestions and losing a few days I hope this helps someone

查看更多
做个烂人
5楼-- · 2019-01-05 09:01

recreating provisional files fixed my all problems.

查看更多
▲ chillily
6楼-- · 2019-01-05 09:02

I tried out all the answers listed here but no one solved my issue. In my case this error is due to my silly mistake in Appid creation. I used Wildcard App ID instead of using Explicit App ID caused the problem

If you want an application to receive remote notifications(push notification), then you need to use an Explicit App ID, such as com.tutsplus.push, instead of com.tutsplus.*

Please find the ScreenShot, enter image description here

查看更多
别忘想泡老子
7楼-- · 2019-01-05 09:05

I had a similar issue. I've been bouncing between XCode 7 and 8 for a variety of reasons. Once you use 8 to build, you will need to use 8. I simply used Xcode 8 and applied some of the changes suggested above and it worked.

查看更多
登录 后发表回答