Get users to review your app with StoreKit and Swift
Let’s face it, we all love a 5-star rating from a user. For me, it makes all the work that I put into making my apps worthwhile and what better way to get reviews than to ask for them yourself. So, in this article I’ll show you how to present those cute little pop-ups that ask the user to rate your app and, if they choose to, also write a review.
For this tutorial, we’ll use a framework called StoreKit. So, go ahead and import StoreKit.
The main challenge with presenting a “Hey you like my app? Care to give a review?” view isn’t actually the presentation of the view but the time and location at where you present that alert. If used correctly the alert can increase your app store rankings by a lot however they can also cause severe obtrusion to the whole UX so it is very important to present the pop-up at times during the UX where you’re certain that the user is really engaging with your app. (Examples: Do not present the pop-up right after a user opens the app for the first time. Wait for at least 10–20 app launches before the pop-up pops up on the screen.). To do this first we’ll set an integer to a UserDefaults. If you don’t know what UserDefaults are you can check out the article here but basically, they are values that remain constant throughout app launches and reset only when the app is uninstalled. In your viewDidLoad() function make a new UserDefault that contains an integer and has an identification key called “appOpenCount”.
Next, declare a variable that will contain the value of the UserDefault and then increment it by 1. I’ll call this “newAppOpenCount”. Then, increment its value by 1. This means that every time the view loads the value of newAppOpenCount will increase by 1. Also, set the value of the new count to the UserDefault.
Next, we’ll use a switch case to trigger the pop-up view on certain nth app launch.
We’ll switch the variable “currentAppOpen” as this has the integer that is the number of the present app launch.
If the user has launched the app at least 10 times you can safely assume that they like using your app and therefore it is a good time to trigger the function requestReview() which is a part of the StoreKit framework. Feel free to modify the case to suit your needs.
That’s it. Your app will now request for a review from your user when the user seems to be engaging quite well with your app! If you liked this article and learned something new from it feel free to leave as many claps as you wish :)