我满足推送通知的所有要求。 在 iTunes 连接中启用功能,然后创建分发配置文件。
在 Debug模式下,我的应用程序调用:didRegisterForRemoteNotificationsWithDeviceToken
。
但在发布构建应用程序调用中: didFailToRegisterForRemoteNotificationsWithError
出现错误:
Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application"
在项目中我有 xxx.entitlements:
<dict>
<key>aps-environment</key>
<string>production</string>
</dict>
我的 xxx.mobileprovision 包含以下字符串:
<key>Entitlements</key>
<dict>
<key>keychain-access-groups</key>
<array>
<string>XXXXXXXXXX.*</string>
</array>
<key>get-task-allow</key>
<false/>
<key>application-identifier</key>
<string>XXXXXXXXXXX.MyBundleId</string>
<key>com.apple.developer.team-identifier</key>
<string>XXXXXXXXXXX</string>
<key>aps-environment</key>
<string>production</string>
</dict>
导出 Ad hoc 包后,我使用命令codesign -d --entitlements MyApp.app
<key>application-identifier</key>
<string>XXXXXXXXXXX.MyBundleId</string>
<key>com.apple.developer.team-identifier</key>
<string>XXXXXXXXXXX</string>
<key>get-task-allow</key>
<false/>
<key>keychain-access-groups</key>
<array>
<string>XXXXXXXXXXX.MyBundleId</string>
</array>
其中 XXXXXXXXXXX 是团队 ID,并且各处都是相等的。
谁能告诉我这个错误是什么原因造成的?提前致谢!
最佳答案
发生这种情况是因为我在启用推送功能后在项目设置中使用手动签名。之后,在 project.pbxproj 中,相应构建(发布)的 buildSettings
部分不包含
CODE_SIGN_ENTITLEMENTS = MyApp/MyApp.entitlements; string.
通过在项目设置中重新启用推送功能解决了此问题。
关于ios - 仅在发布版本中找不到适用于应用程序的有效 'aps-environment' 权利字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54589218/