Post

Replies

Boosts

Views

Activity

Test subscribe on test flight
Hi! I created a subscription class and a button that starts the purchase flow. In the Xcode environment and Simulator everything works correctly — the purchase sheet appears and the subscription flow works as expected. But when I test the app in TestFlight, the subscription button doesn’t appear at all. I cannot trigger a purchase, and I can’t find a clear tutorial that explains how to make subscriptions work specifically in TestFlight. Here is what I have already done: I created the subscription in App Store Connect I set up a Sandbox account and logged in on the device. StoreKit sync works and the product ID matches the one in App Store Connect. The same code works perfectly in Xcode Debug and Simulator, but the button is missing in TestFlight. I’m totally stuck. Can someone explain how to correctly set up and test subscriptions in TestFlight and why the subscription button would disappear even though everything works in Xcode? Any help or guidance would be greatly appreciated! THIS IS SUB CLASS @Published private(set) var products: [Product] = [] @Published private(set) var activeSubscriptions: Set<StoreKit.Transaction> = [] private var updates: Task<Void, Never>? var hasActiveSubscription: Bool { activeSubscriptions.contains { transaction in guard let expirationDate = transaction.expirationDate else { return false } return expirationDate > Date() && transaction.revocationDate == nil } } init() { updates = Task { for await update in StoreKit.Transaction.updates { if case .verified(let transaction) = update { activeSubscriptions.insert(transaction) await transaction.finish() } } } } deinit { updates?.cancel() } // MARK: PRODUCT LOADING func fetchProducts() async { do { let ids = ["test_name"] products = try await Product.products(for: ids) } catch { print("Failed to load products: \(error)") products = [] } } // MARK: PURCHASE func purchase(_ product: Product) async throws { let result = try await product.purchase() switch result { case let .success(.verified(transaction)): await transaction.finish() case .success(.unverified): break case .pending: break case .userCancelled: break @unknown default: break } } // MARK: ACTIVE SUBSCRIPTIONS func fetchActiveSubsciptions() async { var active: Set<StoreKit.Transaction> = [] for await entitlement in StoreKit.Transaction.currentEntitlements { if case .verified(let transaction) = entitlement { active.insert(transaction) } } self.activeSubscriptions = active } > ``` THIS IS BUTTON ```VStack(spacing: 8) { ForEach(sub.products) { product in PrimaryButtonView(text: mainButtonTitle) { Task { do { try await sub.purchase(product) } catch { print("Purchase error: \(error)") } } } } }```
0
0
33
1w