iTunes api, lookup by bundle ID?

后端 未结 5 762
予麋鹿
予麋鹿 2020-12-01 05:44

Is there any way to use the iTunes API to lookup information based on the unique app bundleId? I have an iphone app, I want to use the API to check to see if the user has th

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 06:04

    Thanks to all above answers. Here is code in 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)
        }
    

提交回复
热议问题