Set rating directly in the app (Swift 3, iOS 10.3)

I have a menu button in my application. If the user clicks this button, they see a UIAlertView that includes an app link in the App Store.

Here is the code:

@IBAction func navButton(_ sender: AnyObject) {

let alertController = UIAlertController(title: "Menu", message: "Thanks for using our app!", preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "Rate Us on the App Store", style: .default, handler: { (action: UIAlertAction) in
print("Send user to the App Store App Page")

let url  = URL(string: "itms-apps://itunes.apple.com/app/id")
     if UIApplication.shared.canOpenURL(url!) == true  {
     UIApplication.shared.openURL(url!)
}  
}))

      

I know that iOS 10.3 introduced the ability to set a rating in the app. What should I change so that when the user clicks on the link in the UIAlertView he can set the rating right in the app?

I found some information on the Apple Developer website ( https://developer.apple.com/reference/storekit/skstorereviewcontroller ) but I don't know how to do this in my application.

+3


source to share


1 answer


This is one class function based on document view.

SKStoreReviewController.requestReview()

      

It also states that you shouldn't call this function depending on the user clicking the button or any other type of action, because it cannot be called. It would be a bad user experience if you indicated that they would be shown on models and then nothing would appear.

If you are using this new option in your application, your best bet is to just place it somewhere that does not interrupt any important user actions and let the framework do the work.

You can use criteria by which the user does not know when to call the function, i.e. launched the app x times, used x for a number of days in a row, etc.



Edit: alternative

If you want more control over your ability to request reviews, you can continue the old path and add the following store URL to take them directly to the review page.

action=write-review

guard let url = URL(string: "appstoreURLString&action=write-review") else { return }
UIApplication.shared.open(url, options: [:], completionHandler: nil)

      

+6


source







All Articles