iTunes api,按包ID查找?

问题描述 投票:21回答:5

有没有办法使用iTunes API根据独特的应用程序bundleId查找信息?我有一个iPhone应用程序,我想使用API​​检查用户是否有最新版本。使用搜索很糟糕,因为它模糊(可以返回大量结果)。我宁愿不必遍历结果集来寻找我的bundleId ..

我不是在设备方面寻找一种方法(不是客观的c)。我想在我的服务器上制作服务器端代码,当苹果进行API更改时,它会隐藏。

iphone ios mobile itunes
5个回答
47
投票

Apple更改了他们的API,并从URL中删除了语言代码,因此您应该只为您正在寻找的应用程序使用bundleId。例如:

http://itunes.apple.com/lookup?bundleId=com.yelp.yelpiphone

此外,您可以将country参数添加到查询中,以获取特定国家/地区App Store的结果。

例如:

http://itunes.apple.com/lookup?bundleId=com.yelp.yelpiphone&country=de

描述,用户评级和其他字段可能会在不同的App Store国家/地区之间发生变化


8
投票

事实证明,您可以使用“Apple ID”而不是捆绑ID,因为它对每个应用程序也是唯一的。 'Apple ID'映射到http://itunes.apple.com/lookup服务中的'trackId'。


6
投票

您可以将包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


3
投票

您可以使用库iVersion来查看用户是否在应用程序中拥有最新版本的应用程序。

iVersion

用于从应用程序内动态检查Mac / iPhone App Store应用程序更新并向用户通知新版本的库。还可以在升级后第一次启动时通知用户应用程序中的新功能。

https://github.com/nicklockwood/iVersion


0
投票

感谢以上所有答案。这是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)
    }
© www.soinside.com 2019 - 2024. All rights reserved.