<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/storeProductTask(for:priority:action:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewP010_StoreKit_aB0E16storeProductTask3for8priority6actionQrSS_ScPy0dE00G0VADE0H5StateOYactF"
  },
  "title" : "storeProductTask(for:priority:action:)"
}
-->

# storeProductTask(for:priority:action:)

Declares the view as dependent on an In-App Purchase product and returns a modified view.

```
nonisolated func storeProductTask(for id: Product.ID, priority: TaskPriority = .medium, action: @escaping (Product.TaskState) async -> ()) -> some View
```

## Parameters

`id`

The product ID to load from the App Store. The task restarts whenever this parameter
changes.

`priority`

The task priority to use when creating the task.

`action`

The action to perform when the task’s state changes.

## Discussion

Before a view modified with this method appears, a task will start in the background to load
the product from the App Store. While the view is presented, the task will call `action` whenever
the product changes or the task’s state changes.

---

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)