Ios 请求中的应用商店应用版本号错误http://itunes.apple.com/lookup?bundleId=\(标识符)
我正在通过请求从appStore获取我的应用程序的信息字典,并收到1.8.2,但appStore中的版本是1.8.3,如果我在iPhone上安装应用程序-关于应用程序版本的本地信息是正确的1.8.3,为什么appStore请求的版本号不正确Ios 请求中的应用商店应用版本号错误http://itunes.apple.com/lookup?bundleId=\(标识符),ios,swift,Ios,Swift,我正在通过请求从appStore获取我的应用程序的信息字典,并收到1.8.2,但appStore中的版本是1.8.3,如果我在iPhone上安装应用程序-关于应用程序版本的本地信息是正确的1.8.3,为什么appStore请求的版本号不正确 func isUpdateAvailable(completion: @escaping (Bool?, Error?) -> Void) throws -> URLSessionDataTask { guard let info = Bund
func isUpdateAvailable(completion: @escaping (Bool?, Error?) -> Void) throws -> URLSessionDataTask {
guard let info = Bundle.main.infoDictionary,
let currentVersion = info["CFBundleShortVersionString"] as? String,
let identifier = info["CFBundleIdentifier"] as? String,
let url = URL(string: "http://itunes.apple.com/lookup?bundleId=\(identifier)") else {
throw VersionError.invalidBundleInfo
}
print("currentVersion: \(currentVersion)")
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
do {
if let error = error { throw error }
guard let data = data else { throw VersionError.invalidResponse }
let json = try JSONSerialization.jsonObject(with: data, options: [.allowFragments]) as? [String: Any]
guard let result = (json?["results"] as? [Any])?.first as? [String: Any], let version = result["version"] as? String else {
throw VersionError.invalidResponse
}
print("AppStore version: \(version)")
completion(version != currentVersion, nil)
} catch {
completion(nil, error)
}
}
task.resume()
return task
}
//要使用它,我打电话:
_ = try? isUpdateAvailable { (update, error) in
if let error = error {
print(error)
} else if let update = update {
print(update)
}
}
对bundle ID使用
https:
而不是http:
。即使在应用商店显示正确的版本后,我也注意到了同样的事情。在过去的几个月里,苹果版本的服务器发生了一些变化 对bundle ID使用https:
而不是http:
。即使在App Store显示正确版本后,我也注意到了同样的情况。在过去的几个月里,苹果版本的服务器发生了一些变化 自申请发布之日起24小时内,继续返回当前版本的不正确版本号,但原因是什么?如何获得正确的版本号?自应用程序发布之日起24小时内,仍会返回当前版本的错误版本号,但原因是什么?如何获得正确的版本号?