Search code examples
iosswiftin-app-purchasepromotion-code

Swift showing Promo Code View for In App purchase not doing anything


I tried adding a function for Promo-Codes so I can give some users something for free.

I created a Promo-Code inside App Store Connect and this is my function to open the PromoCodeView:

@objc func promoCodeButtonTapped() {
    let paymentQueue = SKPaymentQueue.default()
    if #available(iOS 14.0, *) {
        paymentQueue.presentCodeRedemptionSheet()
    }
}

The view is presented properly. However I can't do anything there. I can type in a code or cancel but I can not confirm or anything. What am I missing here?? I am running it on the live-version btw. I know I can not test it in development.

The App is live! If you want to test it yourself:

https://apps.apple.com/de/app/wishlists-einfach-w%C3%BCnschen/id1503912334

Generated Promo Code for the In-App Purchase:

HE9T64F74JHT

If one can make it work, he can get Premium of my app for free with this code :D (Profile -> Premium Membership -> Promo Code )

enter image description here


Solution

  • You have a slight misunderstanding of how promo codes work, and to be honest, it is a little confusing on Apple's part.

    presentCodeRedemptionSheet is only used to redeem promo codes associated with an auto-renewing subscription. Promo codes for other IAP types are redeemed through the App Store app. Since your IAP is a non-consumable this applies to your app.

    I was able to redeem the code you supplied using the following process:

    1. Access my account in the App Store app (Tap my picture in the top right corner)
    2. Select "Redeem gift card or code"
    3. Paste the code
    4. Open your app and receive the "Thanks for the beer" message (Since the redemption is simply presented to your payment queue observer as a purchase).
    5. There does seem to be an issue with your code, however, as I can't change my profile picture and I get an error that I need to be a premium user.
    6. I tried to purchase the upgrade directly and got a message from Apple that it was free since I already owned it; but I am still a Llama :(

    You can remove the "Promo code" button from your UI; It isn't applicable in your case.