Replies: 1 comment 2 replies
-
Thanks again for another great point, following up from the first issue in openiap. 1. Cache productsThe docs currently say “Cache products to avoid repeated fetches”, but in fact, you don’t need to handle this at the application level. AsyncFunction("getItems") { (skus: [String]) -> [[String: Any?]?] in
// Fetch products from StoreKit
let fetchedProducts = try await Product.products(for: skus)
// Add fetched products to the cache
await productStore.performOnActor { isolatedStore in
fetchedProducts.forEach { product in
isolatedStore.addProduct(product) // Cache the product
}
}
// Retrieve all cached products
let products = await productStore.getAllProducts()
return products.map { serializeProduct($0) }
} To clarify:
I’ll fix the misleading line in the docs right away. Thank you again for catching this! 2. API differences between
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Documentation for useIAP() says
Cache products to avoid repeated fetches
but it looks like it's already done with fieldssubscriptions
andproducts
, or am I missing something?I try to prefetch products, so they are ready to go when opening offer page. But as long as in the previous library the context used to hold it, here it's all gone and need to be re-fetched every time useIAP() is used, unless we introduce back the context or similar solution.
Here documentation says
Returns: Promise resolving to array of products
, but it's not, it returnsPromise<void>
.Also there is undocumented function
restorePurchases
. How it should be used, considering restore purchase process may be complicated like restoring user in app credits?Here documentation say to import
initConnection
, but afaik that seams to be not needed as it's handled automatically by useIAP() now. Is that correct?Beta Was this translation helpful? Give feedback.
All reactions