StoreView
A view that merchandises a collection of In-App Purchase products.
Declaration
@MainActor @preconcurrency struct StoreView<Icon, PlaceholderIcon> where Icon : View, PlaceholderIcon : ViewOverview
A StoreView displays a collection of in-app purchase products, including their localized names, descriptions, and prices, and displays a purchase button.
Create a store view by providing a collection of product identifiers for the view to load from the App Store, or a collection of Product values you previously loaded. If you provide product identifiers, the store view automatically loads the product information from the App Store, and updates the view when the products are available.
You can provide a view to use as an icon or image for each individual product. If you provide product identifiers, you can optionally provide placeholder icons for the system to use instead of the automatic placeholder icon.
If you set up promoted images for your products in App Store Connect, you can choose to display those images for your products.
Manage the store layout
The StoreView arranges products in rows. If the view has enough horizontal space available, the store adds columns. In tvOS, the view arranges the products in columns and adds rows as space permits.
The store view grows to fit its container, and scrolls when the container doesn’t have enough space to display all the products. Use the fixedSize(horizontal:vertical:) modifier to change this behavior.
To achieve a custom layout, you can compose ProductView instances with other container views instead of using the StoreView.
Customize the store
You can customize the store by displaying additional buttons, and applying styles.
To display a button that syncs in-app purchase entitlements with the App Store, modify the in-app store view or an ancestor view using the storeButton(_:for:) modifier with the parameters Visibility.visible and restorePurchases. The app calls the sync() method when people use this button.
You can customize the appearance of the products using product view styles, such as CompactProductViewStyle, LargeProductViewStyle, and RegularProductViewStyle. To apply the style, call the productViewStyle(_:) modifier.
Topics
Creating store views that load products
init(ids:prefersPromotionalIcon:)init(ids:prefersPromotionalIcon:icon:)init(ids:prefersPromotionalIcon:icon:placeholderIcon:)init(ids:icon:placeholderIcon:)
Creating store views with preloaded products
init(products:prefersPromotionalIcon:)init(products:prefersPromotionalIcon:icon:)init(products:icon:)