AppStoreReviewManager is a simple utility to prompt the users of your iOS or macOS apps to submit a review after a certain number of runs.
This utility by default will not immediatly call for an app review, instead it keeps track until a minimum threshold of calls is hit before prompting the user for a review. It will also only request one review for each app version that is released.
Example: Version 1.0 - The user will be prompted the 5th time they launch the app to give a start rating and write a review. Launches 6+, they will not be prompted again. App is updated to version 1.0.1 - The user will be prompted after the 5th launch of this new version to review
Basic (no completion block, will prompt after the app calls this 5 times)
AppStoreReviewManager.requestReview()
If you want to have a different minimum threshold
AppStoreReviewManager.requestReview(minimumActionCount: 5)
A custom completion block (if you're like me and want to report some analytics on this event)
AppStoreReviewManager.requestReview(completion: { (success, appVersion?) in
// success: Bool - If the user was prompted for a review
// appVersion: String? - What version of the app the user was prompted for
}
All of the goodies, if you want to customize the minimum threshold and want a callback
AppStoreReviewManager.requestReview(minimumActionCount: 0) { (success, appVersion?) in
// success: Bool - If the user was prompted for a review
// appVersion: String? - What version of the app the user was prompted for
}
Recommended placement is in the AppDelegate.swift file in the didFinishLaunchingWithOptions
function. That way the user isn't spammed and it's guaranteed to check once per app launch.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
/* ... other startup stuff */
AppStoreReviewManager.requestReview()
}