purchase(confirmIn:options:)
Initiates a purchase for the product with the App Store and displays the confirmation sheet.
Declaration
@MainActor func purchase(confirmIn scene: some UIScene, options: Set<Product.PurchaseOption> = []) async throws -> Product.PurchaseResultParameters
- scene:
The Uiscene the system uses to show the purchase confirmation UI.
- options:
A set of options (Purchaseoption) you can associate with the purchase.
Return Value
The result of the purchase, Product.PurchaseResult.
Discussion
StoreKit provides several APIs you can use to enable customers to initiate a purchase. Before using purchase(confirmIn:options:), consider the following APIs and choose the one that best suits your app’s implementation:
Use PurchaseAction for apps that use SwiftUI on any platform, including multi-scene apps for visionOS.
Use purchase(confirmIn:options:) for apps that use UIKit.
Use purchase(confirmIn:options:) for apps that run on macOS and use AppKit.
Use purchase(options:) for apps that runs on watchOS.
This method may throw a Product.PurchaseError or StoreKitError.