Skip to main content

Cancelling Purchases.shared.purchase(package: Package)


Forum|alt.badge.img+1

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

cody
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 492 replies
  • February 21, 2023

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.


Forum|alt.badge.img+1
  • Author
  • New Member
  • 1 reply
  • February 23, 2023

@cody 

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?


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings