Is it possible to get app id from iOS application programmatically?

前端 未结 6 1045
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-01 11:59

Is there any way for getting appstore id from running iOS application? (For asking user to rate it and providing link to appstore.)

6条回答
  •  一整个雨季
    2021-01-01 12:29

    get the app id like this

    guard let bundleID = Bundle.main.infoDictionary?["CFBundleIdentifier"] as? String else {
        return
    }
    
    let url = "https://itunes.apple.com/lookup?bundleId=\(bundleID)"
    
    Alamofire.request(url).responseJSON { response in
        guard let value = response.result.value else { return }
        let json = JSON(value)  // from: import SwiftyJSON
        let storeVersion = json["results"][0]["version"].stringValue
    
        let storeProductID = json["results"][0]["trackId"].intValue
        // result: 1506562619
        
    }
    

提交回复
热议问题