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

新上架App用HTTP+Bundle ID查询App Store版本失败求助

首次上架App的HTTP+Bundle ID查询App Store信息失败问题

我用以下Swift代码读取App Store中已注册应用的版本,用于对比提示更新:

static func checkStoreVersion(completion: @escaping (String?) -> Void) {
    guard let info = Bundle.main.infoDictionary,
    let identifier = info["CFBundleIdentifier"] as? String else {
        return completion(nil)
    }
    
    guard let url = URL(string: "http://itunes.apple.com/kr/lookup?bundleId=\(identifier)") else {
        return completion(nil)
    }
    
    let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
        guard let data = data,
              let json = try? JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any],
              let results = json["results"] as? [[String: Any]],
              !results.isEmpty,
              let appStoreVersion = results[0]["version"] as? String else {
            print("checkStoreVersion : 0")
            
            return completion(nil)
        }
        print("checkStoreVersion : \(appStoreVersion)")
        return completion(appStoreVersion)
    }
    
    task.resume()
}

这是我首次上架的应用,完成App Store注册后,通过Xcode运行测试时这段代码无法工作,返回resultCount为0。但用浏览器打开该HTTP URL,却能正常获取应用信息。

将URL协议改为HTTPS后代码恢复正常:

guard let url = URL(string: "https://itunes.apple.com/kr/lookup?bundleId=\(identifier)") else {
    return completion(nil)
}

我曾怀疑是Allow Arbitrary Loads配置问题,但用HTTP查询其他已上架应用的Bundle ID时无异常;用Apple ID方式测试HTTP和HTTPS协议也均正常:

// HTTPS方式按ID查询
guard let url = URL(string: "https://itunes.apple.com/kr/lookup?id=\(id)") else {
    return completion(nil)
}
    
// HTTP方式按ID查询
guard let url = URL(string: "http://itunes.apple.com/kr/lookup?id=\(id)") else {
    return completion(nil)
}

问题:为何刚上架的应用,使用HTTP+Bundle ID查询App Store信息会失败?(测试时通过Xcode运行的是相同版本)


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 22:46:17