SKStoreReviewController — Apple在ios 10.3及更高版本中的iOS应用中请求评论和评级的方式

每个应用程序开发人员的目的都是为了获取反馈或对其应用程序进行评论,以更好地展示其应用并鼓励其他人使用他们的应用程序。 通常,开发人员会向其应用程序提供自定义评论UIView以及UIStackview中的星图。 然后,将用户评分记录在后端中,但在进行应用商店评论时,用户通常会说“现在不选择”选项,因为该用户将从当前应用程序的屏幕中退出,进入Apple App Store页面。

我们是否因为这种行为而错过了用户的反馈?

苹果推出了“ SKStoreReviewController”,可在您的应用程序屏幕上显示评论UIView,并记录评论和评论。 无需任何用户导航到Apple应用商店即可提交他/她的评论。 凉。 是不是

三个简单步骤是:

  1. 导入StoreKit。
  2. 检查版本是否为10.3及更高版本。
    if #available(iOS 10.3, *) {
    //call ios API method for review view.
    } else {
    //Use your custom review view.
    }
  3. 从视图控制器调用SKStoreReviewController.requestReview()。
    if #available(iOS 10.3, *) {
    SKStoreReviewController.requestReview()
    } else {
    //Use your custom review view.
    }

多田!

系统将为您提供评论视图和星号,以对应用程序进行评级。
很好,但是在实现“ SKStoreReviewController”视图时,我们必须意识到某些要点。

那些是:

  1. 您仅应在应用程序的用户体验流程中有意义时才调用请求审核,然后仅在用户证明了对应用程序的参与后才调用该方法。
  2. 您无法完全控制发生的事情,显示的对话框或其回调,这完全由系统决定。
  3. 系统可能会显示分级提示,也可能不会显示,因此不适合响应按钮轻击或其他用户操作来调用API,因为这不会每次都发生。
  4. 无论您调用API多少次,系统在365天之内最多只会向同一用户显示3条提示。
  5. App Store默认只显示应用程序的最新版本的评分和评论。
  6. 用户可以在设置中将其关闭。
  7. 苹果将​​来可能会要求这种流程。

苹果的参考链接:https://developer.apple.com/documentation/storekit/skstorereviewcontroller

从我的角度来看,编写“ SKStoreReviewController”的更好方法是:

  1. 为所有与“ SKStoreReviewController”相关的检查,导入和方法编写一个单独的类。

import StoreKit
class kReviewMe {
//All logic and method calls.
}

2.我显示评论视图的逻辑基于任何用户都不启动应用程序。 启动计数将存储在NSUserDefaults中。

/** UserDefauls dictionary key where we store the number of launching the app. **/
let launchCountUserDefaultsKey = “noOfLaunches”

3.决定是否显示查看视图。

/** Get UserDefaults value if its nil or no value found, set the value and there on increment 'launchCount' on every launch. **/

func isReviewViewToBeDisplayed(minimumLaunchCount:Int) -> Bool {
let launchCount = UserDefaults.standard.integer(forKey: launchCountUserDefaultsKey)
if launchCount >= minimumLaunchCount {
return true
} else {
/** Increase launch count by '1' after every launch.**/
UserDefaults.standard.set((launchCount + 1), forKey: launchCountUserDefaultsKey)
}
return false
}

4.从应用程序的任何viewcontroller调用“ showReviewView”方法。

/** This method is called from any class with minimum launch count needed. **/
func showReviewView(afterMinimumLaunchCount:Int){
if(self.isReviewViewToBeDisplayed(minimumLaunchCount: afterMinimumLaunchCount)){
SKStoreReviewController.requestReview()
}
}

5.现在您可以像这样调用“ showReviewView”:

/** call 'showReviewView' method with desired launch counts needed. **/
if #available(iOS 10.3, *) {
kReviewMe().showReviewView(afterMinimumLaunchCount: 2)
}else{
// Review View is unavailable for lower versions. Please use your custom view.
}

最小启动计数是Int值,我们决定启动计数的数量。
链接到示例项目:https://github.com/kavitha89/kReviewMe.git