How to use requestReview (SKStoreReviewController) to show review popup in the current viewController after a random period of time
In your AppDelegate:
Swift:
import StoreKit
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let shortestTime: UInt32 = 50
let longestTime: UInt32 = 500
guard let timeInterval = TimeInterval(exactly: arc4random_uniform(longestTime - shortestTime) + shortestTime) else { return true }
Timer.scheduledTimer(timeInterval: timeInterval, target: self, selector: #selector(AppDelegate.requestReview), userInfo: nil, repeats: false)
}
@objc func requestReview() {
SKStoreReviewController.requestReview()
}
Objective-C:
#import <StoreKit/StoreKit.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
int shortestTime = 50;
int longestTime = 500;
int timeInterval = arc4random_uniform(longestTime - shortestTime) + shortestTime;
[NSTimer scheduledTimerWithTimeInterval:timeInterval target:self selector:@selector(requestReview) userInfo:nil repeats:NO];
}
- (void)requestReview {
[SKStoreReviewController requestReview];
}
The code above will ask Apple to prompt the user to rate the app at a random time between 50 and 500 seconds after the app finishes launching.
Remember that according to Apple's docs, there is no guarantee that the rating prompt will be presented when the requestReview is called.
Swift: SKStoreReviewController - how often can it be called?
In short, you choose the appropriate time to display the alert, but the system will decide whether to actually show the alert or not. So don't worry about "over-calling" as long as you don't call it as a response to user interaction.
Although you should call this method when it makes sense in the user experience flow of your app, the actual display of a rating/review request view is governed by App Store policy. Because this method may or may not present an alert, it's not appropriate to call it in response to a button tap or other user action.
Highlight mine.
https://developer.apple.com/documentation/storekit/skstorereviewcontroller/2851536-requestreview
As for your second question, the only reference I can find regarding how many times it might be displayed is "3 times per year". It doesn't mention 3 times per app version or update. Use this API wisely.
open write review page using SKStoreReviewController with query parameters action=write-review
here i what i am using
let appID = "Your App ID on App Store"
let urlStr = "itms-apps://itunes.apple.com/app/id\(appID)?action=write-review"
if let url = URL(string: urlStr), UIApplication.shared.canOpenURL(url) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
Is SKStoreReviewController helpful in writing a review?
The Submit button of the prompt of requestReview()
will redirect you to the Write a Review page of the app, with the stars section already filled out. You can optionally enter a title and a detailed review there. (The description text is misleading, the title is optional.)
From the Ratings, Reviews, and Responses - App Store page of Apple Developer:
Users will submit a rating through the standardized prompt, and can authenticate with Touch ID to write and submit a review.
Related Topics
iOS Provisioning and Certifcates - Will Revoke/Renew Effect App Store Apps
Adding Glow Effect to Uibutton - iOS
Sudzc Arc Version - Objc_Msgsend Call Causes Exc_Bad_Access Using 64-Bit Architecture
iOS 4.3 Hide Status Bar Permanently
Xcode Crash Organizer Does Not Symbolicate .Xccrashpoint Files
How to Schedule Local Notification for the Following Scenario
Swift - Uiimagepickercontroller - How to Use It
iOS 13 - How to Login in In-App Purchase Sandbox Account
Libmobilegestalt Mobilegestaltsupport.M:153 Mobilegestalt.C:550 Xcode Console
Getting Button Action:Uicollectionview Cell
Swift "Bridging-Header.H" File Not Allowing Me to Instantiate Objective-C Classes in .Swift Files
Creating Thumbnail for Video in iOS
Issue with Auto Layout on iOS 8 (Code Works Perfectly on iOS 7)
Swift - Coredata Migration - Set New Attribute Value According to Old Attribute Value
Nsattributedstring Inserting a Bullet Point
Swift If Statement - Multiple Conditions Separated by Commas