I use StoreKit's StoreView to buy in-app purchases. The purchase is working in the simulator, but how can I restore purchases? I did not find a restore handler, there is only a onInAppPurchaseCompletion but I'm missing a onRestorePurchaseCompletion or similar.
This is how it looks
This is my code:
StoreView(ids: ["my.product.id"])
.storeButton(.visible, for: .restorePurchases)
.storeButton(.hidden, for: .cancellation)
.onInAppPurchaseCompletion { product, result in
if case .success(.success(let transaction)) = result {
print("Purchased successfully: \(transaction.signedDate)")
isPremium = true
} else {
print("Something went wrong")
}
}

When using StoreKit 2 UI the Restore Purchases button behaves the same as calling
AppStore.sync()This refetches the entitlements from App Store. There is thus no handler for it provided, as any missing entitlements should be added as a successfully completed purchase on the
onInAppPurchaseCompletionhandler. Additionally, any missing entitlements will also be added into theTransaction.currentEntitlementsafter user clicks the button and authenticates on the App Store.You can read more about this behaviour in this post and here.