Use this page with AI
Copy this into your coding assistant and add your request.
Read https://openiap.dev/docs/apis/ios/current-entitlement-ios and https://openiap.dev/llms.txt. Follow the reading instructions, detailed reference, and linked guides relevant to my task before making changes.
Inspect my existing project and reuse its framework and conventions. Ask me for missing product decisions. Implement the requested behavior and run the applicable checks.
Show the working result, the commands and actual test results, and any remaining limitations. Keep your explanation brief.
My request: [describe what customers should be able to do]iOS currentEntitlementIOS
Get current StoreKit 2 entitlement for a product (iOS 15+, macOS 14+).
Uses Product.currentEntitlements where available and otherwise filters Transaction.currentEntitlements by SKU. This avoids StoreKit's deprecated singular Product.currentEntitlement property. Generic Advanced Commerce SKUs can yield multiple current transactions, so OpenIAP returns the latest verified entitlement by purchase date and transaction ID. See the Apple StoreKit reference.
Signature
swift
func currentEntitlementIOS(sku: String) async throws -> PurchaseIOS?Parameters#
sku(required,string) — Product identifier.
Returns#
Promise<PurchaseIOS | null> — iOS purchase shape, or null if the SKU has no matching transaction.
Example
swift
let entitlement = try await OpenIapModule.shared.currentEntitlementIOS(sku: "com.app.premium")