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 http://stackoverflow.com/questions/10987102/how-to-fix-no-valid-aps-environment-entitlement-string-found-for-application 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!

John
  • 1,677
  • 4
  • 15
  • 26

3 Answers3

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

mickeymoon
  • 4,820
  • 5
  • 31
  • 56
2

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

nahlamortada
  • 489
  • 6
  • 16
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

El_boogy
  • 145
  • 4