avatarStephanie De Smedt

Summary

The website content provides a guide on how to prompt users to rate and review an app in the App Store using SwiftUI and the StoreKit framework, with a focus on timing the request appropriately based on user engagement.

Abstract

The article "Requesting App Store Ratings with SwiftUI" is a comprehensive guide aimed at app developers looking to increase user reviews for their applications. It emphasizes the importance of user feedback for an app's success and visibility in the App Store. The initial implementation involves using the StoreKit framework's built-in requestReview function, which can be triggered by a button click within the app. However, the article advises that developers should fine-tune the timing of this prompt to ensure users have had a chance to sufficiently engage with the app. An example is provided where the review prompt is set to appear on the third time the user views the welcome screen, using AppStorage to track the number of app opens. The article concludes by reminding developers to consider the optimal timing for review prompts, balancing between capturing user feedback and not interrupting the user experience with premature requests.

Opinions

  • The author suggests that having multiple positive reviews can significantly benefit an app's reputation and attractiveness to potential users.
  • It is the author's view that developers should not rely solely on users' initiative to leave reviews but should instead actively prompt them.
  • The author believes that the timing of the review prompt is crucial and should be tailored to the user's experience with the app, avoiding excessive or premature prompts.
  • The use of AppStorage for tracking the number of app launches is recommended by the author for determining when to trigger the review prompt.
  • The article encourages reader interaction by inviting comments for further clarification and sharing of implementation plans.
  • The author promotes their Medium profile and newsletter subscription, indicating a belief in the value of their content and a desire to build a readership.

Requesting App Store Ratings with SwiftUI

A how-to guide on asking users to rate and review your app in the App Store

Rating and Review Screen

When launching a new app getting user reviews and feedback is really important. An app with multiple (positive) reviews will make you stand out from the competition and show people that your app it is worth trying out. In ideal world all users that like your app will leave a review, however, unfortunately this isn't usually the case. Having an alert to prompt people to leave a review is an excellent way to build up a base of feedback. This post will walk you through the steps needed to do just that.

Initial Implementation

Creating a ratings and review alert is actually a built-in part of Apple's StoreKit framework so we begin by using “import StoreKit” at the top of the view where we will want the alert to appear. The next step is to access the necessary Environment key — which is called requestReview. Finally, call this requestReview() property which will prompt the user to leave a review.

The code snippet below puts those steps into action. In this specific example there is a “Leave a review” button and when it is clicked the alert window will appear asking for a rating/review.

import StoreKit
import SwiftUI

struct RatingAlertCode: View {
   
    @Environment(\.requestReview) var requestReview
    
    var body: some View {
        
        Button("Leave a review") {
            requestReview()
        }
   
    }
}

Fine tuning

Although that method works, it is not very practical. Usually you would like your user to have used to app for a while before being prompted to leave a review. The right time for this prompt can vary depending on your app and should be adjusted accordingly.

In this post we will take the example where we want the user to be asked for a review on the 3rd time they see the welcome screen.

To do this, first create a variable that is saved into the AppStorage memory called “openCount”. Whilst AppStorage variables should be used sparingly it's perfect for cases such as this where it is a property that uses only a small amount of memory.

Every time the view is displayed increment the varaible by one. This can be done using the onAppear modifier on the main VStack of the view. Then within the same modifier add in an 'if' statement that will trigger the review alert when this variable reaches 3.

The alert will only show the once so as not to bother any users with excess pop-ups.

struct ReviewAppCode: View {
    
    @Environment(\.requestReview) var requestReview
    @AppStorage("openCount") private var openCount = 0

    var body: some View {
        VStack{
            Text("Welcome to my App")
                .font(.headline)
            Text("You have opened the app \(openCount) times")
        }.onAppear(perform: {
            openCount += 1
            if openCount == 3 {
                requestReview()
            }
        })
    }
}

Summary

Adding a review alert is a great way to encourage users to rate your app and increase the chance more people discover the product you have worked so hard on making. Although simple to implement time should be taken to consider the best timeframe for prompting a review. Do not wait too long so as to capture as many users a possible, however also allow people enough time to use the app before leaving a premature rating.

Hopefully this was helpful... Let me know in the comments if anything could be explained better or how you plan to implement into your own projects!

Thanks for reading! If you liked this post and want to read more, be sure to check out my profile or subscribe for similar posts.

Subscribe to Medium to gain unlimited access to all the content and ideas available. If you join Medium through this link I will receive a tiny amount from your fees — and it will not cost you any extra!

Level Up Coding

Thanks for being a part of our community! Before you go:

🚀👉 Join the Level Up talent collective and find an amazing job

Swift
App Development
iOS
Programming
Xcode
Recommended from ReadMedium