在这个问题上卡住了很长一段时间。尝试运行以下行:
[application registerForRemoteNotifications];
并得到错误
(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.
这包括: 1)重新创建配置文件 2) 重新创建 ID 并检查它是否匹配并启用推送 3)清理重建等 4) 创建新证书 5) 使用 Xcode > Preferences > Accounts > View Details 刷新(选择你的账户)
想知道是否有人对此有任何解决方案?
很高兴分享人们可能认为对解决此问题有用的任何其他信息。
非常感谢您的帮助!
最佳答案
转到 Capabilities
部分下的项目 Target,您会发现此错误发光。 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>
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>
将这两个文件添加到 Build Settings 的 Code Signing Entitlments 下适当的选项下。
关于ios - 获取 token 失败,错误: Error Domain=NSCocoaErrorDomain Code=3000 "no valid ' aps-environment' entitlement string found for application",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29440627/