Skip to content

Commit

Permalink
fix date set
Browse files Browse the repository at this point in the history
  • Loading branch information
w-i-n-s committed Jun 3, 2021
1 parent 0c9ed45 commit 258c96b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions NthKey/Model/SubscriptionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,14 @@ final class SubscriptionManager: NSObject, ObservableObject {
/// Allow to have raw estimation of subscription vithout validation
private func checkExpirationDateFromPayment(_ payment: SKPayment) {
let productId = payment.productIdentifier
for item in ["month": 30, "year": 365] {
for item in ["month": (1,0), "year": (0,1)] {
guard productId.contains(item.key) else { continue }
let date = Date(timeIntervalSinceNow: TimeInterval(60*60*24*item.value))

var dateComponent = DateComponents()
dateComponent.month = item.value.0
dateComponent.year = item.value.1

let date = Calendar.current.date(byAdding: dateComponent, to: Date())
UserDefaults.subscriptionDate = date
checkPurchaseStatus()
}
Expand Down

0 comments on commit 258c96b

Please sign in to comment.