Contents

PurchaseIntent

An instance that emits purchase intents, which indicate that the customer initiated a purchase outside of your app, for your app to complete.

Declaration

struct PurchaseIntent

Mentioned in

Overview

Using PurchaseIntent is required in the following cases:

  • If you promote in-app purchases on the App Store

  • If you turn off the Streamlined Purchasing setting in App Store Connect and use win-back offers or contingent pricing

You set up these offers and settings in App Store Connect. For more information, see Promote in-app purchases, Set up win-back offers, and Manage Streamlined Purchasing.

When a customer selects a promoted product on the App Store or a win-back offer outside of your app, it initiates a purchase that they complete in your app. If they don’t have your app installed, the system prompts them to download it. After the app downloads, the transaction continues in the app, which receives a purchase intent from the intents sequence.

The purchase intent identifies the product the customer selected. To enable customers to complete the purchase, call purchase(options:) on this product instance. The following example code receives the purchase intent, and calls a method to complete the purchase workflow:

func purchaseProduct(_ product: Product) async {
    // Complete the purchase workflow.
    do {
        try await product.purchase()
    }
    catch {
        // Add your error handling here.
    }
    // Add your remaining purchase workflow here.
}

for await purchaseIntent in PurchaseIntent.intents {
    // Complete the purchase workflow.
    await purchaseProduct(purchaseIntent.product)
}

For more information, see Supporting promoted In-App Purchases in your app and Supporting win-back offers in your app.

In Mac apps built with Mac Catalyst, this instance doesn’t emit purchase intents for promoted in-app purchases because the Mac App Store doesn’t support this feature.

Topics

Identifying the product

Getting purchase intents

Identifying the offer

See Also

Promoted In-App Purchases