Adam Rush

@Adam9Rush

27 June, 2022

This article was written using Xcode 14 and iOS 16 Beta 1

Introduction

Requesting an iOS Review in SwiftUI is a brand new way to getting feedback from your users. It is an essential step into building a relationship with them and getting valuable feedback to improve your app continuously.

You might be familiar with this popup presented to you when using iOS applications.

Apple introduced this functionality to make it easier for you to request a review; the result is that it will appear on the App Store page. It helps showcase your amazing app to others and will sure help with downloads.

Previously, there was only a way to do this in UIKit via the StoreKit framework; however, in SwiftUI 4.0, we have a brand new environment variable to access this prompt.

Requesting a Review

In your real-world application, you’ll likely trigger this once your users have used the app for some time, or perhaps they have completed the first level of the game.

import SwiftUI
import StoreKit

struct ContentView: View {
    @Environment(\.requestReview) var requestReview
    var body: some View {
        VStack {
            Button {
                requestReview()
            } label: {
                Text("Review App")
            }
        }
    }
}

You start by importing the StoreKit framework to your Swift file.

Next, you define the requestReview environment variable, and you can then go ahead and call this within your SwiftUI View.

What Next?

It’s worth reading the Apple Human Interface Guidelines on the rules around displaying the review prompt. It’s useful and contains when and how to display this.

It’s also worth noting that you should only display this once your user has used the application, and having a button is probably not ideal ;].

Sponsor

Subscribe for curated Swift content for free

- weekly delivered.