Solved

Alert "You’re currently subscribed to this..." Bug

  • 7 July 2023
  • 3 replies
  • 269 views

Badge +3

I’m testing on a real device.

I have a purchaseButton, I press it, the subscription is successful. I stop the app, restart it, and when I press the purchaseButton again, I get an alert with a message “You’re currently subscribed to this..." with Manage/Okay buttons. I press the Okay button, nothing happens, the alert gets dismissed. But if I press the Manage button, .purchaseCancelledError: gets hit using breakpoints and the alert gets dismissed.

Now the odd thing is when I press the purchaseButton again, it goes straight to .operationAlreadyInProgressForProductError , at that point I’m able to notify the user that we found their purchase and they can continue on.

So to be clear, the flow is

1- I press the purchaseButton, and after a subscription is initially made, I stop the app

2- After restarting the app, I press the purchaseButton, I get an alert with a message “You’re currently subscribed to this..", however .operationAlreadyInProgressForProductError never gets hit no matter if I press the alert’s Mange or Okay buttons.

3- I then I press the purchaseButton again, and this time it goes straight to .operationAlreadyInProgressForProductError .

The issue is what happens in step 3 should really happen in step 2.

The way it works now, the user has to press the button twice for revenueCat to acknowledge their purchase via .operationAlreadyInProgressForProductError. It looks like a bug.

Code:

func purchaseButtonTapped() {

    Purchases.shared.getOfferings { (offerings, error) in

        if let error = error as? RevenueCat.ErrorCode { return }

        guard let offerings = offerings else { return }

        guard let package = offerings.all.first?.value.availablePackages.first else { return }

        Purchases.shared.purchase(package: package) { (transaction, info, error, userCancelled) in

            if let error = error as? RevenueCat.ErrorCode {

                switch error {

                case .purchaseCancelledError:

                     print(“user either pressed the Manage button from the alert or they cancelled the transaction from the actionSheet”)

                case .productAlreadyPurchasedError, .operationAlreadyInProgressForProductError :

                    // notify user that we acknowledge their subscription and they can continue on to the next level

                default: break

                }

            }

            if userCancelled { return }

                          guard let transaction = transaction else { return }

            guard let info = info else { return }

            let entitlementsInfo: EntitlementInfos = info.entitlements

            print("entitlementsInfo: \(entitlementsInfo)")

        }

    }

}

 

 

icon

Best answer by Haley Pace 19 July 2023, 18:08

View original

3 replies

Userlevel 4
Badge +8

Hi, one thing that may be happening here is that the case purchaseCancelledError may be caught before the productAlreadyPurchasedError can be so it gets skipped. Can you try switching the cases where productAlreadyPurchasedError is checked first and see if that helps?

Badge +3

@Haley Pace

Hi, thanks for the reply :-). I did exactly what you suggested (switching cases), but it made no difference.

 

I’ve been playing with it for a couple of hours and I realize there are 2 different flows happening here. The end result is the same, inconsistency. This is definitely 100% a bug. Please test it or send it to your quality assurance team. I tested this about 10 times. I can also email a video if it would help.

 

-Flow #1, Pressing the Okay button the first time, the callback should be reached. In addition, what happens in C should really happen in B.

-Flow #2, in step B and C, the error code/case from pressing the Manage button is labeled incorrectly because this is the same exact result if the user never made a purchase, the action sheet is presented with the subscription purchase options, and the user either selects the small x to cancel it or swipes to dismiss it.

 

Flow # 1

 

A- I press the purchaseButton, and after a subscription is initially made, I stop the app

 

B- After restarting the app, I press the purchaseButton, I get an alert with a message “You’re currently subscribed to this.." with a Mange and Okay button. I press the Okay button. Nothing happens, the callback from Purchases.shared.getOfferings{...} is never reached and the alert disappears.

 

C- I press the purchaseButton again, the alert doesn't appear, the callback from Purchases.shared.getOfferings{...} is reached and the result is .operationAlreadyInProgressForProductError .

 

Issue here. What happens in C should happen in B. It’s odd because the very first time I press the Okay button, nothing happens, no callback results, but the second time I attempt a purchase, I don't get an alert, but I get a callback result.

 

Flow # 2

 

A- I press the purchaseButton, and after a subscription is initially made, I stop the app

 

B- After restarting the app, I press the purchaseButton, I get an alert with a message “You’re currently subscribed to this.." with a Mange and Okay button. I press the Manage button. The callback from Purchases.shared.getOfferings{...} is reached and the result is .purchaseCancelledError.

 

C- I then press the purchaseButton again and when the alert appears I press the Manage button. The callback from Purchases.shared.getOfferings{...} is reached and again the result is .purchaseCancelledError.

 

Here are the error codes:

error.localizedDescription // The operation couldn’t be completed. (RevenueCat.ErrorCode error 1.)

error.errorCode // 1

error.errorUserInfo // ["rc_code_name": "PURCHASE_CANCELLED", "NSDebugDescription": "Purchase was cancelled."]

 

Issue: Pressing the Manage button does nothing because the result is .purchaseCancelledError.. As a user, you would expect Manage to do something other than the alert just disappearing. On the developer’s side, because pressing Manage results in .purchaseCancelledError., there really is no way for us to handle that other than doing nothing.  The returned result shouldn’t be .purchaseCancelledError., because the user isn't cancelling the purchase. The error code/case is labeled incorrectly.

 

D- I press the purchaseButton, I get an alert with a message “You’re currently subscribed to this.." with a Mange and Okay button. I press the Okay button. Nothing happens, the callback from Purchases.shared.getOfferings{...} is never reached and the alert disappears.

 

E- I press the purchaseButton, the alert doesn't appear, the callback from Purchases.shared.getOfferings{...} is reached and the result is .operationAlreadyInProgressForProductError .

Userlevel 4
Badge +8

Thank you for letting me know, I have escalated this to our engineering team and will reach back out if we need more information or when we have resolved this.

Reply