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

前端 未结 13 1025
面向向阳花
面向向阳花 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:25

    For iOS 10.3+ you can use SKStoreReviewController with simple dialog, and choose rating in alert-style window. To use it, you should import StoreKit library. So, universal way to rate your app inside itself is like this:

    import StoreKit
    
    func rateApp(){
       if #available(iOS 10.3, *) {
          SKStoreReviewController.requestReview()
       } else {
          guard let url = URL(string: "itms-apps://itunes.apple.com/ru/app/cosmeteria/id1270174484") else {
             return
          }
    
          if #available(iOS 10.0, *) {
             UIApplication.shared.open(url, options: [:], completionHandler: nil)
          } else {
             UIApplication.shared.openURL(url)
          }
       }
    }
    

    And when you try to launch it in simulator, you won't see App Store window, so try it on device and it gonna work. This way covers all iOS versions, using all abilities. And the part of path in you application address "/us/app" means your App Store localisation, for example "us" means USA. You can easily find your app id in address string just by opening app in App Store in any browser.To get the link, just copy address in browser. Changing "https://" for "itms-apps://" lets you to open app in App Store application, while "https" opens web page in Safari

提交回复
热议问题