I've seen a few topics on stackoverflow on promo codes handling: Detecting promo code, Handling promo code, Consumable promo codes and none of them have the right answer. There are some swift guides on how to create and redeem promo codes for in-app purchases, but nobody talks about what's happening later.
Redeeming an (in-app purchase) promo code on the AppStore:
Some people say it's all you have to do (and then when the user chooses payment there's suddenly no 9,99$ information, but something like 'Use promo code', which StoreKit handles behind the scenes). I'm afraid that doesn't work like that.
Should I handle it somehow in the AppDelegate - if there's a transaction coming right after the app launches (meaning that someone used promo code)? Should I present an alert telling the user he used the promo code, and unlock the functionality or add some 'gems' to his account (if it's consumables)?
EDIT: There are also these two apple developer forum topics: Few people have the same problem - no answer, Apple staff responded about where to place transactionObserver
EDIT2: Or perhaps promo codes cannot be applied to consumable products, which are used once and cannot be restored (using in-app promo codes is based on restoring I've read somewhere?)
Promotional codes are alphanumeric strings that online stores offer to encourage purchases on their website and are typically associated with an overarching promotional marketing strategy. The discount associated with a promo code can apply to individual products or an entire order.
To use a coupon, click on the offer, and a window will appear where you can copy the code. When you check out on the store's website, paste the code in the promo code field. Stores sometimes call this a promo code, but it is also known as a promotional code, coupon code or, discount code. How do I use a coupon code?
For those who got stuck like me.
Indeed you need to declare a class (e.g. PurchaseHelper) importing StoreKit with SKProductsRequestDelegate and SKPaymentTransactionObserver extensions inside AppDelegate.
Then if the user redeems a promo code inside App Store - and he opens your app - 'updatedTransactions' func gets called and it's the only time you can do something with the purchased product.
What I did was - save an info/transactionId to UserDefaults, so in the main screen user gets an alert like "You redeemed a promo code. Choose your favorite spot and click Purchase to get it for free".
Of course a better solution is to do enable the product right away in the AppDelegate. If your promo code gives the user 100$ (consumable) then you can just add it (but there's still question if he is logged in).
If you know any better solutions, please tell me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With