Search code examples
swiftxcodein-app-purchaseapp-storesubscription

Listening for "Promoting Your In-App Purchases" event within the application


We offer and support the subscription product on the App Store page of the application as follows.

https://developer.apple.com/app-store/promoting-in-app-purchases/

When the user clicks the "subscribe" button on the product here, the application opens and the Apple purchases window opens. However, in this flow, I want to add a parental control without opening Apple's purchase window, and if successful, the window for purchasing from Apple will open.

My question is; How can I listen to this process when the application is opened by clicking the buy button from the App Store?


Solution

  • You can use the following method in SKPaymentTransactionObserver and return "true" if the result of the parental control is true;

    func paymentQueue(_ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment, for product: SKProduct) -> Bool {
        return true
    }