You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过App Store Connect API配置Bundle ID的PUSH_NOTIFICATIONS证书?

问题:通过App Store Connect API启用PUSH_NOTIFICATIONS能力后,无法配置对应证书

我正在为新应用搭建CI/CD流程,目前已能通过App Store Connect API创建Bundle ID并启用PUSH_NOTIFICATIONS能力,但无法配置该能力对应的证书。注:我可成功启用PUSH_NOTIFICATIONS能力,但无证书的话该能力无法生效。

启用能力的请求负载如下:

{
    "data": {
        "attributes": {
            "capabilityType": "PUSH_NOTIFICATIONS"
        },
        "relationships": {
            "bundleId": {
                "data": {
                    "id": "<bundleId>",
                    "type": "bundleIds"
                }
            }
        },
        "type": "bundleIdCapabilities"
    }
}

期望实现的效果与App Store Connect控制台操作一致(对应截图)。我已在谷歌、相关论坛及苹果社区搜索,未找到解决方案,且已向苹果支持提交求助请求。


解决方案:通过App Store Connect API创建并关联推送证书

1. 生成推送证书签名请求(CSR)

先通过OpenSSL生成符合苹果要求的CSR文件:

# 生成2048位私钥
openssl genrsa -out push_private_key.pem 2048
# 生成CSR文件,按提示填写信息(Common Name可任意设置)
openssl req -new -key push_private_key.pem -out push_csr.csr

2. 创建推送证书

调用App Store Connect API的certificates端点创建推送证书,请求负载示例:

{
    "data": {
        "attributes": {
            "certificateType": "PUSH_NOTIFICATION",
            "csrContent": "<将push_csr.csr文件内容做base64编码后的字符串>"
        },
        "relationships": {
            "bundleId": {
                "data": {
                    "id": "<你的bundleId>",
                    "type": "bundleIds"
                }
            }
        },
        "type": "certificates"
    }
}

请求成功后,API会返回证书的base64内容,可将其保存为.cer文件,后续可转换为p12格式供项目使用。

3. 关联证书与推送能力

找到之前启用PUSH_NOTIFICATIONS能力时API返回的bundleIdCapability资源ID,调用更新端点绑定证书:

{
    "data": {
        "id": "<已创建的bundleIdCapability的ID>",
        "attributes": {
            "capabilityType": "PUSH_NOTIFICATIONS"
        },
        "relationships": {
            "bundleId": {
                "data": {
                    "id": "<你的bundleId>",
                    "type": "bundleIds"
                }
            },
            "certificates": {
                "data": [
                    {
                        "id": "<刚创建的推送证书ID>",
                        "type": "certificates"
                    }
                ]
            }
        },
        "type": "bundleIdCapabilities"
    }
}

4. 验证配置

调用bundleIdCapabilities的查询接口,确认返回结果中已包含certificates关联信息,此时推送能力即可正常生效。

内容的提问来源于stack exchange,提问作者khalid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 10:15:33