ProductIconPhase
The current phase of the asynchronous loading operation of a product’s promotional image.
Declaration
enum ProductIconPhaseOverview
When you create a ProductIconPhase instance with an initializer such as init(ids:icon:placeholderIcon:), you define the appearance of the view’s icon, or image, using a content closure. SwiftUI calls the closure at different stages of the promotional image’s load operation with a phase value that indicates the current state.
Use the phase to decide what to draw. For example, you can draw a placeholder image during the loading phase, a view that indicates an error, a default image, or the loaded promotional image if it exists:
StoreView(products: [
product1,
product2,
// Additional products, as needed.
]) { product, phase in
switch phase {
case .loading: MyPlaceholder()
case .failure(let error): MyErrorView(error)
case .unavailable: MyDefaultIcon()
case .success(let promotedIcon): promotedIcon
}
}You set up promotional images for in-app purchases in App Store Connect. For more information, see Promote in-app purchases.
Topics
Getting the promotional image’s load phases
ProductIconPhase.loadingProductIconPhase.success(_:)ProductIconPhase.unavailableProductIconPhase.failure(_:)