Cancelling Purchases.shared.purchase(package: Package)

  • 16 February 2023
  • 2 replies


Hey community, I ran into a problem that I can't solve.

When i execute Purchases.shared.purchase(package: Package) as async throws function, i cant really stop the Task { } higher in the call hierarchy and because of that, when user tap subscribe/buy → Task with Purchases.shared.purchase starts to execute → then user close VC or navigate to another → Task is still continues to execute and shows a system bottom sheet with purchase description, price and buy button, but I'm doing everything to cancel task. But nothing works.

Is there any way to cancel a Task that has already started a RevenueCat system call to the StoreKit system ???

2 replies

Userlevel 5
Badge +8

Hey @Sergei!

Before you start a purchase, you should disable your UI or show a loading view, indicating that the purchase is in progress and preventing the customer from navigating away. Once the purchase method completes, you can remove the loading indicator/re-enable the view interaction.



Nice, but the question was about something else entirely - it was about Revenue cat API task cancelling, not about disabling UI while operation executing, coz not allowing the user to leave the screen is a bad way of usability :) Is it possible to cancel entirely running purchase task?