Skip to main content

Cancelling Purchases.shared.purchase(package: Package)

  • February 16, 2023
  • 2 replies
  • 129 views

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 ???

This post has been closed for comments

2 replies

cody
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 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
  • 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?