How can I add a link for a rate button with swift?

前端 未结 13 858
面向向阳花
面向向阳花 2021-01-29 18:57

First I don\'t know how to get the link before I submit my app, and if the link is for each country app store or is it universal?

Also I don\'t know if the way to do it

13条回答
  •  [愿得一人]
    2021-01-29 19:27

    Swift 5.1: The following function sends your user directly to the review section of ANY store, not just on the American one:

    func rateApp(id : String) {
        guard let url = URL(string : "itms-apps://itunes.apple.com/app/id\(id)?mt=8&action=write-review") else { return }
        if #available(iOS 10.0, *) {
            UIApplication.shared.open(url, options: [:], completionHandler: nil)
        } else {
            UIApplication.shared.openURL(url)
        }
    }
    

    Usage:

    rateApp(id: "1287000522")
    

    Important Note: This doesn't work on simulator! Test it on a real device.

提交回复
热议问题