I have this new app I am creating that will use consumable in-app purchases.
My question is this: how does that work? I mean, imagine the user buys a consumable stuff. So, after finalizing the sell I set a flag on the app's database authorizing the use of that object. I read somewhere that I have to provide the user with a button to restore old transactions in case of the user for some reason loses his device and has to restore everything.
Imagine the user has already used that purchase and after that he restores the old in-app purchases. What happens then? Will the user have the same resources again, so he can use a second time without paying? How it works and how should I approach that?
thanks
Consumables are one-shot items, such as ammo, or stickers.
Consumables: User purchases the same product multiple times. Often they're “used up” and bought again. Examples are currency in a free-to-play game, or healing potions, extra lives, etc. Non-consumables: User buys once (and only once), then has access to the item forever.
Select Request a refund or Report a problem. Choose the option that describes your situation. Complete the form and note that you'd like a refund. You'll get a message that says "Thank you for sharing your concerns." You'll also receive an email with a refund decision.
I wanted to share a somewhat unorthodox solution I found to this problem that has the HUGE advantage of not requiring a server. This method allows users to restore their consumable items if the app is deleted and reinstalled, but does not allow them to move the items to a new device (unless all their app data is copied over).
Data stored in the keychain persists when an app is deleted and reinstalled. The keychain is intended for storing usernames and passwords, but you can also store information about consumable purchases in there. I used the KeychainItemWrapper class, available here: https://developer.apple.com/library/content/samplecode/GenericKeychain/Introduction/Intro.html
Here is some sample code where I store and retrieve the number of paid hints that a user has remaining:
//Storing the consumable hint item count int hintsLeft = 100; KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"Hints" accessGroup:nil]; NSString *hintsString = [NSString stringWithFormat:@"%i",hintsLeft]; [wrapper setObject:hintsString forKey:(id)kSecValueData]; [wrapper release]; //Retrieving it KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"Hints" accessGroup:nil]; NSString *numHints = [wrapper objectForKey:(id)kSecValueData]; [wrapper release]; int retrievedHints = [numHints intValue];
Notes:
the key (id)kSecValueData can't be an arbitrary string, there is a set list of constants that you can use as the key.
You will need to add the security framework
StoreKit only provides recovery functionality for non-consumable items (and to some extend for subscriptions). So for consumable products, recovering using restoreCompletedTransactions
will not deliver any transactions in your case. Any handling of restoring information about consumable products must be done within your app and/or server.
For reference of the various products' natures check the In App Purchase Programming Guide:Designing Your App’s Products. There are Consumable products which must be purchased each time, Non-consumable products purchased only once and provided to all devices associated with that user’s iTunes account, Auto-Renewable subscriptions and Non-Renewing Subscriptions
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