我在我的 iOS 应用程序中使用 SKStoreReviewController API 来获取我的应用程序的评论。我也想将其实现到我的 MacOS 应用程序中,但似乎这是不可能的。我导入了 StoreKit,但它显示“使用未解析的标识符‘SKStoreReviewController’”。我是否需要以不同的方式实现这一点,或者这不适合用于 Mac Appstore?
最佳答案
正如 Marek 指出的,SKStoreReviewController
类自 macOS 10.14+ 起可用。
Use the
requestReview()
method to indicate when it makes sense within the logic of your app to ask the user for ratings and reviews within your app.
苹果仍然在 Human Interface Guidelines 中推荐不使用按钮或其他控件来请求反馈和触发,而仅在其他情况下触发。
Apple 有一个不错的 example code处理仅针对特定操作显示的评论:
// If the count has not yet been stored, this will return 0
var count = UserDefaults.standard.integer(forKey: UserDefaultsKeys.processCompletedCountKey)
count += 1
UserDefaults.standard.set(count, forKey: UserDefaultsKeys.processCompletedCountKey)
print("Process completed \(count) time(s)")
// Get the current bundle version for the app
let infoDictionaryKey = kCFBundleVersionKey as String
guard let currentVersion = Bundle.main.object(forInfoDictionaryKey: infoDictionaryKey) as? String
else { fatalError("Expected to find a bundle version in the info dictionary") }
let lastVersionPromptedForReview = UserDefaults.standard.string(forKey: UserDefaultsKeys.lastVersionPromptedForReviewKey)
// Has the process been completed several times and the user has not already been prompted for this version?
if count >= 4 && currentVersion != lastVersionPromptedForReview {
let twoSecondsFromNow = DispatchTime.now() + 2.0
DispatchQueue.main.asyncAfter(deadline: twoSecondsFromNow, execute: {
SKStoreReviewController.requestReview()
UserDefaults.standard.set(currentVersion, forKey: UserDefaultsKeys.lastVersionPromptedForReviewKey)
})
}
即使当我只调用 SKStoreReviewController.requestReview()
时,也没有出现审核提示。有谁知道 macOS 的具体技巧吗?
编辑:我已向应用商店提交了更新,并且审核提示正在运行!我不知道为什么它在测试时没有出现,但在生产中它似乎可以工作!
关于swift - SKStoreReviewController API 是否也适用于 MacOS?如果是,如何实现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46604086/