Home IOS Development ios – Do IAP buttons have callbacks?

ios – Do IAP buttons have callbacks?

0
ios – Do IAP buttons have callbacks?

[ad_1]

I am utilizing RevenueCat for subscriptions. It really works positive after I make the take a look at buy however I am having an odd downside. I’ve a separate “Buy” button, when pressed, the RevenueCat motion sheet seems.

If I press the little x button in the correct hand nook to dismiss it or press outdoors of the actionSheet, inside Purchases.shared.buy, .purchaseCancelledError will get known as. Nonetheless if I press the blue Subscription button, after which press the alert’s Okay, button, nothing occurs. No callbacks get triggered and I do not know that the consumer bought a subscription.

How can I do know when the consumer hits the Subscribe then pressed the OK button from the You are All Set alert?

func purchaseButtonTapped() {

    let productID = "..."

    Purchases.shared.getOfferings { [weak self](choices, error) in
        guard let _ = error else { return }

        for dict in choices.all {
                
            let providing = dict.worth
            let packages = providing.availablePackages
                
            if let indexOfItem = packages.firstIndex(the place: { $0.storeProduct.productIdentifier == productID }) {
                    
                let pkg = packages[indexOfItem]
                    
                self?.showSystemActionSheet(for: pkg)
                break
            }
        }
    }
}

func showSystemActionSheet() {

    Purchases.shared.buy(bundle: bundle) { (transaction, customerInfo, error, userCancelled) in

        if let error = error as? RevenueCat.ErrorCode {
            change error {
            case .purchaseCancelledError: // *** utilizing breakpoints this will get hit after I cancel or dismiss the actionSheet
                return
            case .productAlreadyPurchasedError, .operationAlreadyInProgressForProductError, .receiptInUseByOtherSubscriberError :
                print("buy is lively")
            case .purchaseNotAllowedError:
                print("purchases_not_allowed")
            case .purchaseInvalidError:
                print("invalid_purchase_check_payment_method")
            default: break
            }
            return
        }

        if userCancelled {
            return 
        }

        guard let customerInfo = customerInfo else { 
            return 
        }

        // this could get hit nevertheless it by no means does
        // consumer pressed Subscribe then pressed the OK button from the You are All Set alert
    }
}

enter image description here

enter image description here

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here