无法获取令牌,错误:错误Domain = NSCocoaErrorDomain Code = 3000"找不到有效的'aps-environment'权限字符串用于应用程序"

Joh*_*ohn 6 notifications push-notification apple-push-notifications ios provisioning-profile

已经有一段时间困在这个问题上了.试图运行以下行:

[application registerForRemoteNotifications];
Run Code Online (Sandbox Code Playgroud)

并得到错误

(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. 
Run Code Online (Sandbox Code Playgroud)

这包括:1)重新创建配置文件2)重新创建ID并检查它是否匹配并启用推送3)清理和重建等4)创建新证书5)使用Xcode刷新>首选项>帐户>查看详细信息(选择您的帐户)

想知道是否有人有任何解决方案吗?

很高兴分享人们可能会发现解决此问题的任何其他信息.

非常感谢您的帮助!

mic*_*oon 16

转到你的项目目标下的Capabilities部分,你会发现这个错误发光.XCode可能会建议您自动修复它.在此输入图像描述

您必须在项目中创建两个权利(AppName_Debug.entitlements和AppName_Release.entitlements)文件,其中包含以下内容: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>
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

在适当的选项下,在Build Settings中的Code Signing Entitlments下添加这两个文件.

在此输入图像描述


nah*_*ada 2

您没有有效的配置文件或团队没有