ALL BUSINESS
COMIDA
DIRECTORIES
EDUCATIONAL
ENTERTAINMENT
FASHION TIPS
FINER THINGS
FREE CREATOR TOOLS
HEALTH
MARKETPLACE
MEMBER's ONLY
MONEY MATTER$
MOTIVATIONAL
NEWS & WEATHER
TECHNOLOGIA
TELEVISION NETWORKS
USA VOTES 2024
VIDEOS
INVESTOR RELATIONS
IN DEVELOPMENT
Posted by - Latinos MediaSyndication -
on - October 1, 2023 -
Filed in - Technology -
-
323 Views - 0 Comments - 0 Likes - 0 Reviews
I recently transitioned to StoreKit 2 to handle the active subscription within my app. But there is some aspect of it I'm not entirely sure. The documentation about the revocationDate and expiration date are not clear to me.
If a user cancel his auto-renewable while being in a 7 day trial, will the revocation date be non nil?
Does Transaction.currentEntitlements only contains currently active product? I'm assuming I don't really need to check if the expirationDate is expired or not if that's the case.
Is it recommended to execute this code in the MainThread?
Here is the full method :
@MainActor func syncActiveAppleProduct() async { LoggerManager.shared.warning("[Fetch Current Entitlements]") var activeSubscriptions: [Product] = [] for await result in Transaction.currentEntitlements { do { let transaction = try checkVerified(result) guard let subscription: Product = subscriptions.first(where: { $0.id == transaction.productID }) else { continue } switch transaction.productType { case .autoRenewable: guard transaction.revocationDate == nil else { continue } if let expirationDate = transaction.expirationDate { KeychainHelper.Subscription.setExpiryOrCancelledDate(expirationDate) } activeSubscriptions.append(subscription) case .consumable, .nonConsumable, .nonRenewable: guard let expirationDate = getNonRenewingExpirationDate(forProductId: transaction.productID, purchaseDate: transaction.purchaseDate) else { continue } if Date() < expirationDate { KeychainHelper.Subscription.setExpiryOrCancelledDate(expirationDate) activeSubscriptions.append(subscription) } default: continue } } catch let error { LoggerManager.shared.error(error: error, message: "Failed update active customer product.") } } self.activeSubscriptions = activeSubscriptions }