When to call transaction.finish() when using currentEntitlementTask

When using the new currentEntitlementTask ViewModifier to check for the status of a non-consumable IAP when should you call transaction.finish()?

Also, since currentEntitlementTask will trigger whenever the app/view is run it will call transaction.finish every time. Is it bad to repeatedly call .finish on a already finished transaction?

Currently my app works fine when making purchases and using currentEntitlementTask and @Environment to grant access to the purchased content but I know that all the transactions are unfinished and the docs say you should call transaction.finish() to tell StoreKit that you have given the user access to the content.

Thanks for any help/advice here.

Replies

You should indeed call finish() when you have granted the user access to what they paid for. You can find all unfinished transactions using unfinished, and only call finish() on your transaction if (you delivered it, and) it's not finished yet.