How to guarantee that a consumable in-app purchase will be completed? - ios

I have been working with non-consumable in-app purchases until now and I'm going to use consumables in my next app.
In this new app, I have a lot of items, costing the same price, so, when the user buy one of them, I will use the same in app purchase, and save what item was bought on my server.
Here is the "problem", how can I guarantee that the transaction gonna be completed, no only in my case, but in any in-app purchase, if I have no "restore" option for this kind of IAP?
e.g: The user buys something, and right before my "unlockFeature" method the app crashes. How can I have sure that my user gonna get what he bought?

Related

iOS IAP for limited purchase count of an item. Consumable or not?

If we provide a limited purchasable item to a user, ie 'you can purchase the limited jewel only 3 times', which one is more Apple IAP guideline friendly?
register one Consumable item ('limited jewel': $0.99) and check transaction counts.
register three Non-consumable items (limited jewel 1/2/3) and provide the next purchasable item for each purchase.
or, either looks fine?
Depends on what the user can do with those jewels. If an item can be used once and then it is gone, it is a consumable. If it can be reused over and over, it is a non-consumable.
Consumable
Users can purchase different types of consumables, such as lives or gems in a game, to further their progress through an app. Consumable in-app purchases are used once, are depleted, and can be purchased again.
Non-Consumable
Users can purchase non-consumable, premium features within an app. Non-consumables are purchased once and do not expire, such as additional filters in a photo app.
Source
I suggest you should use the "Consumable" type IAP, it complies with Apple Guideline because it will buy many times. The Non-consumable just use for one time.
After it reaches the third time, you can hide this feature, or prevent the user continue buying.

iOS In App Purchase: Changing from subscription to one time purchase

I am having a programmer code my iOS app, which he has done great. However, due to a new competitor we have decided to change from our current revenue model with In-App Purchases as subscription based to just having users pay a one-time fee. He tells me it'll take a lot of hours to make that change. Is it really true that there is no easy way around changing the code from having renewable purchases to simply have one-time purchases?
Well, this is a very objective question. It's impossible to tell you with any certainty without reviewing the actual code, but here are a few of the obstacles your developer may face:
The methods to buy a subscription is slightly different to buying a non-consumable product, however the app will need to continue to provide content users who are currently paying for a subscription. There is no way to change a subscription to a non-consumable product in iTunes Connect, and you may need to, or should ask and remind the user to cancel their subscription to prevent further renewals (you can't do this yourself or in the app, you can only link to the subscriptions page in their iTunes settings).
The app will need to check for either the subscription product (active or expired) or the non-consumable product has been purchased in order to provide the content. Support for this will need to be on the start of the app, purchase of a product and on the restore in-app purchases function.
There may be further complexities too, particularly if your app uses a backend API that syncs purchase information with a user account.
In conclusion, it's non-trivial, if your developer says it will take a lot of hours, I would be inclined to believe him.

How to detect if user has made any in-app purchases?

My iOS app has in-app purchases (consumable) and shows ads periodically. The idea is to remove ads after user has purchased anything. But in-app items are consumable, so after user re-installs the app, I would be unable to determine if he has purchased anything using [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];, right? And I would bomb him with ads again...
What would you suggest to find out that the user has purchased anything already?
Well when a user re-installs your app (i.e. delete it and install it again) there is no immediate way of knowing what purchases did he made. That's why Apple requires your app to provide a way to restore previous purchases so that when the user performs this operation he restores these purchases for free.
For consumable items you might need to use a server for managing the purchases such that when the app loads it checks with the server which purchases the user has made and immediately enable the relevant content.
I do not know if mandatory but "Remove Ads" IAP should be non-consumable so the user will only need to purchase it once (Otherwise I believe users will complain or just won't buy it).
Some creative ways can be found here : iPhone - in-App purchase consumable correct approach
As an improvement on the situation, you could store the fact that a purchase was made in NSUserDefaults. That won't survive if the user uninstalls and reinstalls the app, but at least it survives if the user buys a new phone and restores a backup to transfer everything to the new phone.
You could have a look at Cloud Kit as well, which would store information per AppleId. It's a bit overkill for the problem, but it means you can use Apple's servers instead of your own for free. There would be a difference that if a user installs your app on six devices, makes a consumable purchase on one device, ads will stop on all of them.

Restore in-app purchase after a set of time

I have created a consumable in-app purchase which enables some images, texts, sound etc. These things should only be available for the user for 4 hours. After that time the same purchase should be available for purchase as normal. My question is how to cancel or restore (or what it's called) the products they buy. Thanks in advance.
I am pretty sure that consumable in app purchase can't be restored. Once they are purchased they are "consumed". If you want to let the user restore purchases for 4 hours after purchase you will need to manually do that yourself. I do something similar to this using Parse (parse.com). When a user makes a purchase it is easy to record that purchase on parse and then I can easily query parse for all purchases a user has made.

iOS InApp Purchase

I just wonder if there is anyway to check if a user(email) already buy an in app purchase item in my application.
For example I buy an item on my iPhone, then I log in on my iPad with same itune account. the application will know that this user did buy the item.
Thanks,
Huy
The same thing is happening when you use the restore purchased option in many applications.
SKPaymentTransactionStateRestored
is the constant retrieved from server when you tries to purchase an already purchased item.
Please check this nice tutorial about inApp purchase : inApp purchases
From the In-App Purchase Programming Guide:
Store Kit provides built-in functionality to restore transactions for
non-consumable products, auto-renewable subscriptions and free
subscriptions.
You can restore purchases with the StoreKit framework by calling the restoreCompletedTransactions method of the SKPaymentQueue. Your app will then receive a transaction for each product the user has previously purchased. Simply handle these transaction and unlock the features and/or download content on the new device.
If your product is a consumable (gold coins for your game, health packs etc.) this would not apply and you have to keep track of the purchases on your own.
You will need to set up a server that will keep track of each transaction. And you need to implement a method to authenticate the user across devices (signup via e-mail, Facebook login etc.). Once the user logs in on a new device, your server can tell the app what it should unlock/download.

Resources