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
...
}