Inapp purchase restoring consumable products - ios

i have uploaded an application which doesnot have webservices, in my application there is an option for user to buy a coin (consumable) using inapp purchases and use these coins to unlock new level. today apple rejected the application and send me following note:
**
Your app uses intermediary currency (coins) to purchase items that
function as non-consumable products (unlocking levels) but does not
include a restore mechanism. Users restore transactions to maintain
access to content that they’ve already purchased.Please modify your
app to include an optional user registration feature that allows users
to restore their purchases to all of their iOS devices. We recommend
indicating that account registration is necessary to restore
previously purchased In-App Purchase products, and providing a way for
users to register later if they wish to access this content in the
future.
**
how can i fix this, as mentioned earlier i dont have a webserver and i cannot use webservices, is there any way around to fix this and get application uploaded.

finally i fixed it by adding login screen in the application and storing user Object in parse.com and when i use inapp purchase i store coins count on Parse and retrieving it on application startup. thanks everyone.

Related

Restore Purchases is Mandatory In case saved in our system?

I searched a lot and did not find a concept for "In-App Purchases restore"
in our application all users can't used without login by email and pass, and all purchases saved in our system to enable multiple platform so the button of restore purchases is mandatory with this case or not?
The App Store Review Guidelines says:
Any credits or in-game currencies purchased via in-app purchase may not expire, and you should make sure you have a restore mechanism for any restorable in-app purchases.
So yes, a restore mechanism is mandatory.
Apple of course doesn't say it needs to be a button. Perhaps you can implement it without any user input; for example at first app startup.
Also, a restore method is mandatory, regardless of where/if you store a purchase. I mean, if you wouldn't have a backend system, you are still required to have a restore mechanism.
(It's good to read all App Store Review Guidelines.)

Can Apple tell me what purchases a user has?

I'm aware of the restore functionality and have implemented it in my apps before, but still has holes in it.
I'm trying to display customized screens based on what apps the user have. Without user interaction, I want to be able to ask apple to retrieve me the in-app purchases that belong to that user for this app?
Other posts mention that I should always keep track of that via calling methods like:
NSUserDefaults.StandardUserDefaults.BoolForKey
But at the same time considers it insecure.
I am currently storing the info in DB. That's easy, but consider the following scenario:
User downloads the app. My DB records that user has 0 in-app purchases. The user later purchases 1 in-app purchase. My DB records that too.
User deletes the app for whatever reason
After a while, he re-downloads the app. My DB at this point starts a fresh and records that the user 0 purchases.
the user sees the in-app purchase (he already bought) and clicks on purchase again.
Here, my execution flow stops and apple picks up... Apple alerts the user that he has already bought the in-app and offers to get it for free.
That message is for the benefit for the user only, and my app is unaware of that. I haven't been able to find a call to apple asking what purchases a user had made for my app? I too, wouldn't want the user to pay again, but be able to always know what purchases he has made in the past at any given point. Why is that information so sealed at apple side? They alrady know the user has may app and I am only asking about in-app purchases in that app.
I am using Xamarin.
You need to refresh the receipt file and then scan through it. It will list all purchases the user has made inside that app, whatever device it was on. This code will let you parse the file and see the purchases made: https://github.com/rmaddy/VerifyStoreReceiptiOS
You could simply make your database store account information the user creates when they want to purchase something from your in-app extras. So in order to make that purchase they have to create a username and password for your app, thus giving you a way to keep track of who owns what in app content without having to ask apple.

Restoring "remove ads" functionality when using consumable IAP

I'm researching how to properly implement the functionality to remove ads in my app when the user makes any IAP and have that functionality restorable.
The way i'm seeing the first part done is to simply put a value in the user defaults that the user has made a purchase and check it before displaying ad. No problem.
But i don't know how to do the restorable part because all my products are consumables. How can I restore this value when the user reinstalls the app? Because as i understand the only record of a consumable is on the device and cannot be restored by apple correct?
Any help would be greatly appreciated, thanks!
You cannot do this purely through store-kit APIs, as there is no restorable purchase record as you say. I can see a couple of options -
You could enable iCloud for your app and persist data to the user's iCloud account, however this won't work for users who don't have iCloud.
You could have the users register an account on your server and use that to store their purchase history (or provide a Facebook login etc).
If a user deletes and re-installs your app then they need to make another in-app purchase to remove the ads - Profit!

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.

How to store in-app purchases for offline availability on per-user basis

It seems that keychain on iOS stores data on a per-app basis rather than per-user.
So if I store information about in-app purchases in the keychain, these products will remain available on the device regardless of which Apple-id is currently logged in.
I could require network-access and perform a restore to know which products should be available, but it seems to be bad practise to do a non user-initiated retore. Also, the app should function properly offline.
My question is: How do I protect in-app purchases from being available to users other than the Apple-id that bought them?
You need to organize user authentication for this - make your users create accounts in your service and provide in your application ability to log in and out for them. After application launch it must check out which user in logged in and provide in-app purchases for that user.

Resources