Use storeButton in a ProductView

77 Views Asked by At

I use a StoreKit2 ProductView to display a product (there is only one). I want to display a button for restorePurchases via storeButton using .storeButton(.visible, for: .restorePurchases, .cancellation) , but apparently this button does not work with ProductView. Does anyone know a workaround for this? Thanks.

1

There are 1 best solutions below

2
son On

Each ProductView equals an id. It's used to fetch the in-app purchase information. You have to provide a valid id for the ProductView appearance, also check your bundleID to match this id too. If not, it will show up like a skeleton loading forever.

In case you just want to call AppStore.sync(). You can use StoreView:

StoreView(ids: ...)
   .storeButton(.visible, for: .restorePurchases)