Contents

currentEntitlementTask(for:priority:action:)

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

Declaration

nonisolated func currentEntitlementTask(for productID: String, priority: TaskPriority = .medium, action: @escaping (EntitlementTaskState<VerificationResult<Transaction>?>) async -> ()) -> some View

Parameters

  • productID:

    The product ID to get the entitlement for. 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 get the current entitlement. While the view is presented, the task will call action whenever the entitlement changes or the task’s state changes.

Consumable in-app purchases will always pass nil to action. For auto-renewable subscriptions, use subscriptionStatusTask(for:priority:action:) to get the full status information for the subscription.

See Also

Interacting with the App Store and Apple Music