Closed drallgood closed 1 year ago
I can't reproduce this in Xcode 14.2.
StoreHelper starts listening for transactions as soon as you call storeHelper.start()
:
@available(iOS 15.0, macOS 12.0, *)
@main
struct StoreHelperDemoApp: App {
@StateObject var storeHelper = StoreHelper()
var body: some Scene {
WindowGroup {
MainView()
.environmentObject(storeHelper)
.task { storeHelper.start() } // Start listening for transactions
}
}
}
@available(iOS 15.0, macOS 12.0, *)
public class StoreHelper: ObservableObject {
:
:
/// Call this method as soon as possible after your app starts and StoreHelper has been initialized.
/// Failure to call` start()` may result in transactions being missed.
/// This method starts listening for App Store transactions and requests localized product info from the App Store.
@MainActor public func start() {
guard !hasStarted else { return }
// Listen for App Store transactions
transactionListener = handleTransactions()
// Get localized product info from the App Store
refreshProductsFromAppStore()
}
}
That's what I thought. It might just be a false positive produced by Xcode
Xcode is reporting this warning at runtime (in Debug mode):
Sources/StoreHelper/Core/StoreHelper.swift:361 Making a purchase without listening for transaction updates risks missing successful purchases. Create a Task to iterate Transaction.updates at launch.