有没有办法使用iTunes API根据独特的应用程序bundleId查找信息?我有一个iPhone应用程序,我想使用API检查用户是否有最新版本。使用搜索很糟糕,因为它模糊(可以返回大量结果)。我宁愿不必遍历结果集来寻找我的bundleId ..
我不是在设备方面寻找一种方法(不是客观的c)。我想在我的服务器上制作服务器端代码,当苹果进行API更改时,它会隐藏。
Apple更改了他们的API,并从URL中删除了语言代码,因此您应该只为您正在寻找的应用程序使用bundleId
。例如:
此外,您可以将country参数添加到查询中,以获取特定国家/地区App Store的结果。
例如:
http://itunes.apple.com/lookup?bundleId=com.yelp.yelpiphone&country=de
描述,用户评级和其他字段可能会在不同的App Store国家/地区之间发生变化
事实证明,您可以使用“Apple ID”而不是捆绑ID,因为它对每个应用程序也是唯一的。 'Apple ID'映射到http://itunes.apple.com/lookup服务中的'trackId'。
您可以将包ID与Search API一起使用。只需用id
替换bundleId
,如下所示:
http://itunes.apple.com/lookup?bundleId=com.facebook.Facebook
编辑:正如@Roman Blachman所说,国家代码逻辑已发生变化。如果要将结果限制为特定国家/地区,请使用以下示例。
http://itunes.apple.com/lookup?bundleId=com.facebook.Facebook&country=us
您可以使用库iVersion来查看用户是否在应用程序中拥有最新版本的应用程序。
iVersion
用于从应用程序内动态检查Mac / iPhone App Store应用程序更新并向用户通知新版本的库。还可以在升级后第一次启动时通知用户应用程序中的新功能。
感谢以上所有答案。这是swift 4.2中的代码
guard let info = Bundle.main.infoDictionary,
let identifier = info["CFBundleIdentifier"] as? String,
let url = URL(string: "http://itunes.apple.com/lookup?bundleId=\(identifier)") else { return }
do {
let data = try Data(contentsOf: url)
guard let json = try JSONSerialization.jsonObject(with: data, options: [.allowFragments]) as? [String: Any] else {
return
}
if let result = (json["results"] as? [Any])?.first as? [String: Any],
let version = result["version"] as? String {
print("version in app store", version)
}
} catch let erro as NSError {
print(erro.description)
}