Contents

callAsFunction(_:options:)

Starts an in-app purchase for the indicated product and purchase options.

Declaration

@MainActor @preconcurrency func callAsFunction(_ product: Product, options: Set<Product.PurchaseOption> = []) async throws -> Product.PurchaseResult

Parameters

  • product:

    The in-app purchase Product the customer is purchasing.

  • options:

    A set of options you may associate with the purchase (Purchaseoption).

Return Value

The result of the purchase, Product.PurchaseResult.

Discussion

Don’t call this method directly. SwiftUI calls it when you call the PurchaseAction structure with the product and options as arguments.

This method may throw a Product.PurchaseError or StoreKitError.

For information about how Swift uses the callAsFunction(_:options:) method to simplify call site syntax, see Methods with Special Names in The Swift Programming Language.