没有为应用程序找到有效的“aps-environment"权利字符串 [英] no valid 'aps-environment' entitlement string found for application

查看:69
本文介绍了没有为应用程序找到有效的“aps-environment"权利字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试配置我的应用程序以支持推送通知,但不断收到此错误:无法获取令牌,错误:错误域=NSCocoaErrorDomain Code=3000没有为应用程序找到有效的‘aps-environment’授权字符串" UserInfo=0x1f818fc0 {NSLocalizedDescription=没有为应用程序找到有效的‘aps-environment’授权字符串}

  • 我确实让我的应用支持推送通知(目前仅用于开发).
  • 我确实在启用推送通知后创建了配置文件.
  • 我的包标识符与配置文件中显示的相同.
  • 在我的配置文件中有一个字符串:aps-environment
  • 我确保在代码签名身份"部分下的项目和目标中,所有值都被选为我的配置文件.

还有什么想法吗?谢谢.

解决方案

就我而言,我的配置文件中的内容:

security cms -D -i ~/Downloads/spolskyDevelop.mobileprovision...<key>应用标识符</key><string>P5GM95Q9VV.com.dca.spolsky</string><key>aps-environment</key><string>开发</string>

与实际构建的应用程序中的内容不同(您可以通过查看 Xcode 的日志"选项卡找到它的构建位置)

codesign -d --entitlements - '/Users/drew/Library/Developer/Xcode/DerivedData/spolsky-bdbtdfjeeywhqzccpmmceqvnhgtm/Build/Products/Debug-iphoneos/spolsky-ios.app'<字典><key>应用标识符</key><string>Y2X6Z7Z2GR.com.dca.spolsky-ios</string><key>get-task-allow</key><真/><key>keychain-access-groups</key><阵列><string>Y2X6Z7Z2GR.com.dca.spolsky-ios</string></阵列></dict>

这是真的即使代码签名标识下的当前匹配"提示文本指示正确的配置文件——很奇怪,是吧?为了让奇怪的故事更奇怪,我运行时在设备上安装了正确的配置文件,(设置->常规->配置文件)让我相信配置文件是正确的——但它又回到了通配符ID应用实际启动的时间.

线索是这两个命令的输出不同:

Y2X6Z7Z2GR.com.dca.spolsky-ios vs P5GM95Q9VV.com.dca.spolsky

当我使粗体部分匹配时,斜体部分更改为自动匹配.另外,安全性和codesign的输出一致,没有更多的aps-entitlement错误.

我的猜测是 XCode 在我的非通配符 ID 上使用了通配符样式的匹配.(毕竟,spolsky"几乎是spolsky-ios"),这解释了当前匹配"输出.但是构建链中的某些内容对此更为严格,因此在构建期间它会回退到实际通配符 ID.

I am trying to configure my app to support push notification, but keep getting this error: Failed to get token, error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x1f818fc0 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}

  • I did enable my app to support push notifications (only for development at this point).
  • I did create the provisioning profile AFTER enabling the push notifications.
  • My bundle identifier is the same as appears in the profile.
  • In my profile file there is a string: aps-environment
  • I made sure that in both project and target under the "Code signing identity" section ALL the values are selected to be my provisioning profile.

Any more ideas? Thanks.

解决方案

In my case, the stuff in my provisioning profile:

security cms -D -i ~/Downloads/spolskyDevelop.mobileprovision 
...
<key>application-identifier</key>
<string>P5GM95Q9VV.com.dca.spolsky</string>
<key>aps-environment</key>
<string>development</string>

Was different than the stuff in the app that was actually built (you can find out where it is built by looking at Xcode's Logs tab)

codesign -d --entitlements - '/Users/drew/Library/Developer/Xcode/DerivedData/spolsky-bdbtdfjeeywhqzccpmmceqvnhgtm/Build/Products/Debug-iphoneos/spolsky-ios.app'
<dict>
    <key>application-identifier</key>
    <string>Y2X6Z7Z2GR.com.dca.spolsky-ios</string>
    <key>get-task-allow</key>
    <true/>
    <key>keychain-access-groups</key>
    <array>
        <string>Y2X6Z7Z2GR.com.dca.spolsky-ios</string>
    </array>
</dict>

This was true even though the "Currently Matches" hint text under Code Signing Identity was indicating the correct provisioning profile--weird, huh? To make a weird story weirder, the correct provisioning profile was being installed on the device when I ran, (Settings->General->Profiles) leading me to believe the provisioning profile was right--but it was falling back to a wildcard ID when the app was actually launched.

The clue was the difference in the output of these two commands:

Y2X6Z7Z2GR.com.dca.spolsky-ios vs P5GM95Q9VV.com.dca.spolsky

When I made the bolded part match, the italicized part changed to match automatically. In addition, the output of security and codesign were in agreement, and no more aps-entitlement error.

My guess here is that XCode was using a wildcard-style match on my non-wildcard ID. ("spolsky" is, after all, quite nearly "spolsky-ios"), and this explains the "Currently Matches" output. But something in the build chain is more strict about this, so it falls back to an actual wildcard ID during the build.

这篇关于没有为应用程序找到有效的“aps-environment"权利字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆