Question

Need Assistance with RevenueCat Subscription Implementation

  • 26 May 2023
  • 1 reply
  • 52 views

Hello everyone,

I apologize for the double post, as there was an issue with the previous one where some of my private data got published unintentionally. I appreciate your understanding.

Now, I'm facing a challenge while implementing subscription functionality using RevenueCat, and I could really use your guidance. Here's the scenario:

When a user clicks on any subscription plan on the paywall, I disable the buttons to prevent multiple clicks. However, I'm unsure how to handle the situation when the user closes the subscription sheet without completing the subscription process. This leaves them on the paywall without re-enabling the buttons.

I would greatly appreciate any advice or suggestions on how to catch this event or find a solution that allows me to re-enable the buttons in this specific case. My goal is to ensure a seamless user experience, even when users accidentally close the subscription window.

Button(action: {
isProcessing = true
if let package = subscriptionManager.packages?.first(where: { $0.identifier == "$rc_lifetime" }) {
Purchases.shared.purchase(package: package) { (transaction, purchaserInfo, error, userCancelled) in
if purchaserInfo?.entitlements.all["PREMIUM"]?.isActive == true {
subscriptionManager.updateInfo()

} else {
isProcessing = false
showAlert = true
alertTitle = "Purchase Failed"
alertMessage = error?.localizedDescription ?? "An unknown error occurred."
}
}
}
}) {
VStack {
Text("$24.99 One-Time Payment")

Text("Lifelong access")

}

}

Thank you all in advance for your assistance. I look forward to your response and resolving this issue.


1 reply

Userlevel 4
Badge +6

Hey @pilsen83,

I went ahead and removed that other post for you!

Regarding your question - in order to ensure that users are able to use the paywall buttons even if they accidentally closed the window, I’d recommend using the `userCancelled` parameter of purchasePackage to see if the user did cancel (accidentally or otherwise) and reinstate the paywall buttons. 

`userCancelled` will be `true` if the user clicked out of the subscription window: https://revenuecat.github.io/purchases-ios-docs/4.19.1/documentation/revenuecat/purchases/purchase(package:completion:)

Reply