Failed to get token, error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application"
Asked Answered
W

3

12

Been Stuck on this one issue for quite a while now. Trying to run the following line:

[application registerForRemoteNotifications];

and getting the error

(via: - (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
    NSLog(@"Failed to get token, error: %@", error);
})

2015-04-03 16:06:42.753 TownHall[696:169453] Failed to get token, error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x17426a1c0 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}

Tried some of the stuff with the following associated post https://mcmap.net/q/150452/-how-to-fix-quot-no-valid-39-aps-environment-39-entitlement-string-found-for-application-quot-in-xcode-4-3 but little luck. 

This includes: 1) Recreating a provisioning profile 2) Recreating ID and checking that it matches and has push enabled 3) Clean and rebuild, etc 4) Creating of new certificates 5) Refresh with Xcode > Preferences > Accounts > View Details (Select your account)

Wondering if anyone has any solutions for this?

Happy to share any other information that people might find useful for solving this problem.

Thanks a lot in advance for help!

Wrangle answered 3/4, 2015 at 22:39 Comment(5)
Post error message pleasePosition
Added more info above if it helps. The error message is just the title...Wrangle
if there's entitlement in build settings, could you try to delete it? another possible reason, you can use iphone configuration utility to delete all provision except the latest onePosition
where do I find entitlement?Wrangle
It is in build settings/code signing section, but if you project doesn't use entitlements file, then I can guess provision issue?Position
S
22

Go to your projects Target under Capabilities section, you'll find this error glowing. XCode may suggest to fix it for you automatically.enter image description here

You'll have to create a two entitlements(AppName_Debug.entitlements and AppName_Release.entitlements) file within your project with the following content: AppName_Debug.entitlements

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
      <dict>
        <key>aps-environment</key>
          <string>development</string>
      </dict>
</plist>

AppName_Release.entitlements

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
      <dict>
        <key>aps-environment</key>
          <string>production</string>
      </dict>
</plist>

Add these two files under Code Signing Entitlments in Build Settings under appropriate option.

enter image description here

Sherer answered 27/9, 2016 at 8:35 Comment(0)
G
2

You don't have a valid provisioning profile or team is none

Gaynor answered 11/5, 2015 at 15:13 Comment(2)
How do I check whether the provisioning profile is valid or not?Phillisphilly
the .p12 file associated to your profile is not valid check it on the keychainGaynor
R
0

IF you see the error 'entitlement string not found for application', add the aps-environment and development key value pair in the entitlements file like stated above

Rabbit answered 18/1, 2020 at 5:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.