mirror of
https://github.com/lil-org/tokenary.git
synced 2024-12-02 09:33:49 +03:00
29 lines
744 B
Swift
29 lines
744 B
Swift
// Copyright © 2021 Tokenary. All rights reserved.
|
|
|
|
import StoreKit
|
|
|
|
struct ReviewRequster {
|
|
|
|
static func requestReviewIfNeeded() {
|
|
if let lastDate = Defaults.latestReviewRequestDate {
|
|
if Date().timeIntervalSince(lastDate) > 190 * 24 * 3600 {
|
|
requestReview()
|
|
}
|
|
} else {
|
|
if Defaults.reviewRequestsGoodMomentsCount >= 2 {
|
|
requestReview()
|
|
} else {
|
|
Defaults.reviewRequestsGoodMomentsCount += 1
|
|
}
|
|
}
|
|
}
|
|
|
|
private static func requestReview() {
|
|
#if os(macOS)
|
|
SKStoreReviewController.requestReview()
|
|
Defaults.latestReviewRequestDate = Date()
|
|
#endif
|
|
}
|
|
|
|
}
|