我将应用商店的应用版本号与应用的现有版本号进行比较。而且现在工作正常,这不是因为JSON
的版本字段中不再写入版本号,而是字符串“应用说明更改” 了吗?
class func isUpdateAvailable() -> Bool {
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 {
print("Invalid info")
return false
}
do {
let data = try Data(contentsOf: url)
guard let json = try JSONSerialization.jsonObject(with: data, options: [.allowFragments]) as? [String: Any] else {
print("Version error")
return false
}
if let result = (json["results"] as? [Any])?.first as? [String: Any], let version = result["version"] as? String {
print("version in app store", version,currentVersion);
print(result)
let versionInStoreD = Double(version)! //SO I HAVE A CRASH HERE
let currentVersionD = Double(currentVersion)!
if versionInStoreD > currentVersionD {
return true
} else {
return false
}
} else {
return false
}
} catch {
return false
}
}
喜欢这个JSON
"version": "App description change", "contentAdvisoryRating": "17+", "trackName": "BlaBlaBla", "kind": "software", "artistName": "BlaBlaBla", "sellerName": "BlaBlaBla"
修改后的更新问题
这是我在应用程序连接中找到的内容。除了版本号,我还有一个文字“ 应用说明更改”,我真的不知道为什么,但是我该如何更改呢?我的应用已通过批准并已在商店中。