Closed shop

This commit is contained in:
lumaa-dev 2024-10-05 13:45:41 +02:00
parent 9e198fe9a9
commit 0749bf2222
2 changed files with 24 additions and 15 deletions

View File

@ -53,22 +53,22 @@ public class AppDelegate: NSObject, UIWindowSceneDelegate, Sendable, UIApplicati
}
/// This function uses the REAL customer info to access the premium state
static func hasPlus(completionHandler: @escaping (Bool) -> Void) {
Purchases.shared.getCustomerInfo { (customerInfo, error) in
guard let error else {
let hasPrem: Bool = hasActuallyPlus(customerInfo: customerInfo)
completionHandler(hasPrem)
return
}
fatalError(error.localizedDescription)
}
}
// static func hasPlus(completionHandler: @escaping (Bool) -> Void) {
// Purchases.shared.getCustomerInfo { (customerInfo, error) in
// guard let error else {
// let hasPrem: Bool = hasActuallyPlus(customerInfo: customerInfo)
// completionHandler(hasPrem)
// return
// }
// fatalError(error.localizedDescription)
// }
// }
/// This function returns a fake "true" value every time whatever the customer info is
// static func hasPlus() -> Bool {
// self.premium = true
// return true
// }
static func hasPlus(completionHandler: @escaping (Bool) -> Void) {
self.premium = true
completionHandler(true)
}
private static func hasActuallyPlus(customerInfo: CustomerInfo?) -> Bool {
return customerInfo?.entitlements[PlusEntitlements.lifetime.getEntitlementId()]?.isActive == true || customerInfo?.entitlements[PlusEntitlements.monthly.getEntitlementId()]?.isActive == true || customerInfo?.entitlements[PlusEntitlements.yearly.getEntitlementId()]?.isActive == true

View File

@ -13,7 +13,7 @@ public struct ShopView: View {
@State private var purchaseError: Bool = false
@State private var hasSub: Bool = false
@State private var canPay: Bool = true
@State private var canPay: Bool = false
@State private var displayErr: Bool = false
@State private var strErr: String = "Bbl404"
@ -116,6 +116,14 @@ public struct ShopView: View {
}
}
.task {
#if DEBUG
self.canPay = true
#else
self.canPay = false
#endif
guard canPay else { return }
Purchases.shared.getOfferings { offerings, err in
if let err {
self.canPay = false
@ -140,6 +148,7 @@ public struct ShopView: View {
}
} message: {
Text(strErr)
//TODO: http://rev.cat/why-are-offerings-empty issue
}
.sheet(isPresented: $showSub) {
ShopView.SubView()