Skip to main content
Solved

Best practice to tell if purchase is in progress (including across re-launch)

  • September 26, 2024
  • 1 reply
  • 32 views

ptorab
Forum|alt.badge.img

I’m relatively new to iOS/Swift, and completely new to the RC SDK. I’ve made some progress with the SDK purchase flow and Apple sandbox testing. I’m trying to figure out the best practice to determine if a purchase is in progress—something robust that can persist across app re-launch—so the UI can properly reflect that.

From the sample app (Magic Weather) code and documentation, Swift try/await format (which I assume is recommended over completion handlers) seems to be the proper way to call purchase(). Is this correct?

Managing an isPurchasing property, as in the sample code below, is straightforward; what if the purchase takes longer than user’s patience, and for that (or any other) reason, app is terminated and re-launched before purchase is complete? Is there any API that could return something like “purchase in progress” or similar to help get the fresh app state back on track? Is this something that apps even consider?

do {

    let result = try await Purchases.shared.purchase(package: package)

    isPurchasing = false

    if !result.userCancelled { isPresented = false }

} catch {

    isPurchasing = false

    purchaseError = error as NSError

    ...

}

 

Best answer by Haley Pace

Hi, we do not have an API or SDK method to check if a purchase is in progress, but if the app is terminated or something else happens to interfere with the purchase progress, the app stores will cancel the purchase so there is no need to worry about handling this case.

View original
Did this post help you find an answer to your question?
This post has been closed for comments

1 reply

Forum|alt.badge.img+8
  • RevenueCat Staff
  • 512 replies
  • Answer
  • September 30, 2024

Hi, we do not have an API or SDK method to check if a purchase is in progress, but if the app is terminated or something else happens to interfere with the purchase progress, the app stores will cancel the purchase so there is no need to worry about handling this case.


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