Post

Replies

Boosts

Views

Activity

currentEntitlementTask latency and inconsistency
Hi, I have the following implementation for a non-consumable IAP. In the relevant SwiftUI views: currentEntitlementTask(for: "com.example.FullApp") { state in self.appUnlocked = await AppStoreWrapper.shared.appUnlocked(verification: state.transaction) } and AppStoreWrapper: actor AppStoreWrapper { static let shared = AppStoreWrapper() private var updatesTask: Task<Void, Never>? func observeTransactionUpdates() { self.updatesTask = Task { [weak self] in for await update in Transaction.updates { guard let self else { break } await self.process(transaction: update) } } } func process(transaction verificationResult: VerificationResult<Transaction>) async { guard case .verified(let transaction) = verificationResult else { return } if case .nonConsumable = transaction.productType { await transaction.finish() } } func appUnlocked(verification: VerificationResult<Transaction>?) -> Bool{ guard let verification = verification, let transaction = try? verification.payloadValue else { return false } return transaction.revocationDate == nil } } The problem now is that on app launch, there is some latency until some views appear unlocked. It takes around 5 seconds to unlock everything and sometimes some instances of the same view remain to appear locked even after a while. Is this an expected behaviour of currentEntitlementTask? should I store the purchase state somewhere else like UserDefaults to mitigate this latency? I thought that UserDefaults are insecure to store this information, what's the best practice here?
0
0
203
Sep ’24