<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/preferredSubscriptionOffer(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewP010_StoreKit_aB0E26preferredSubscriptionOfferyQr0dE07ProductV0gH0VSgAH_AH0G4InfoVSayAJGtcF"
  },
  "title" : "preferredSubscriptionOffer(_:)"
}
-->

# preferredSubscriptionOffer(_:)

Selects a subscription offer to apply to a purchase that a customer makes from a subscription
store view, a store view, or a product view.

```
nonisolated func preferredSubscriptionOffer(_ offer: @escaping (Product, Product.SubscriptionInfo, [Product.SubscriptionOffer]) -> Product.SubscriptionOffer?) -> some View
```

## Parameters

`offer`

A closure that returns the subscription offer to apply to the customer’s purchase.

## Discussion

Subscription stores within this view use the subscription offer you specify to configure the
appearance of the subscription plans. <doc://com.apple.documentation/documentation/StoreKit/ProductView>
doesn’t display the terms of a subscription offer in the UI, but you can still use this modifier to
declare which offer product views within a view hierarchy apply to a purchase.

Offer preferences that use this modifier override offer preferences from ancestor views.

> Important: Subscription offers in the
> <doc://com.apple.documentation/documentation/StoreKit/Product/SubscriptionInfo>
> object may contain offers the customer isn’t eligible for. Instead, use the
> eligibleOffers argument of the offer closure to select the offers to apply to the
> customer’s purchase.

If StoreKit determines that the customer is eligible for more than one offer, the system calls the
`offer` closure before it draws the product on the subscription store view, or before the customer
initiates a purchase on a store view or product view. Return the subscription offer to apply to the
product, if any, to have system-provided UI reflect the discounted pricing terms under the
selected offer.

If your `offer` closure returns nil, the system selects the introductory offer, if it exists, and if the
customer is eligible for it.

The following code example sets the preferred subscription offer to the first offer the customer
is eligible for:

```
import SwiftUI
import StoreKit

@available(iOS 18.0, macOS 15.0, tvOS 18.0, watchOS 11.0, visionOS 2.0, *)
struct MyView: View {

    var body: some View {
        SubscriptionStoreView(groupID: groupIdentifier)
            .preferredSubscriptionOffer { product, subscription, eligibleOffers in
                // Determine the offer to use from the list of eligibleOffers.
                // This example just uses the first offer.
                return eligibleOffers.first
            }
    }
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)