在iOS 14中,Xcode显示了一个警告:
requestReview()‘在iOS 14.0中被废弃
我正在使用StoreKit在我的应用程序中自动要求评审。
func requestReview() {
guard shouldRequestReview else {return}
SKStoreReviewController.requestReview()
lastRequest = Date()
}
怎样才能摆脱这个警告?
发布于 2021-01-05 03:47:27
iOS(13及以上)和macOS的简单解决方案
iOS (Swift 5+):
if #available(iOS 14.0, *) {
if let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
SKStoreReviewController.requestReview(in: scene)
}
} else if #available(iOS 10.3, *) {
SKStoreReviewController.requestReview()
}
macOS:别忘了用id123456789替换你的苹果ID
guard let writeReviewURL = URL(string: "https://itunes.apple.com/app/id123456789?action=write-review") else {
print("Invalid URL")
return
}
NSWorkspace.shared.open(writeReviewURL)
https://stackoverflow.com/questions/63953891
复制相似问题