Is it possible to check if a user bought an in-app purchase without having him to login to his Apple ID/AppStore first?
(The reason I'm asking is because I would like to restore previously bought items automatically for returning users)
This isn't possible without user interaction. And you shouldn't worry about it either. Apple does lay importance to it, but only to the point that you should put the button to restore previous purchases visibly enough.
Related
After reading Apple's terms with my average English I understand that all application who sell non-consumable item need to use the IAP and insert a "restored button" if not the application is rejected by apple.
My user need to be connected to an account to play in my game and the IAP is attached to his account. And the non-consumable item is a money that he can spend. So I can't add a "restore button"...
So my question is, compared to my project do I really have to install a restore button? And if yes, how?
Update
I found my answer :
Apple documentation
So I don't need a restored button because I've sell consumable item.
The simplest solution is to look, how other similar apps work.
Add a restore button somewhere in settings. User taps the restore button.
If user is logged in, then his balance is automatically restored from the account on your server and you just tell him, that his balance is restored.
If he is not logged in, you should tell him, that he should login to restore his balance and then show him a login view.
All this should be reproducable by AppStore's app tester.
I've working code to make or restore purchase. I'm able to buy and restore.
My idea is to put two buttons on purchase screen: "Buy" and "Restore".
I want to eneble/disable those buttons depending on purchase status.
Simply:
If user not bought yet -> "Buy" enabled and "Restore" disabled
If user bought alredy -> no purchase screen :)
If user bought alredy and reinstal app - "Buy" disabled and "Restore" enabled
Of course I'm using standardUserDefaults but problem starts whe user reinstal app. My question is how to get purchase status from appStore (purchased or not yet)?
You shouldn't do this because Apple requires to always have a restore button or your app will get rejected.
You also shouldn't disable or hide the buttons depending if something was bought or restored.
If the user presses the buy button on a product he already bought he just gets the product for free again, you are never charged twice.
So I wouldn't even bother trying to do this. It also properly makes your users experience more confusing. Better to have a consistent shop experience that doesnt change all the time. Also users might be thinking there is a bug in your game because all they see is a button that doesnt work.
Maybe put a little tick or something next to the buy button if you want to indicate to the user that he already bought the item. You must have some sort of bool or other property that gets set, and saved in NSUserDefaults, once a product was bought. Just use that property to add or remove the tick/indicator.
If you are wondering how to handle the restore button on first press you should use the restore completed delegate method. There you can basically show 2 UIAlertControllers.
1 if nothing restored because nothing was previously bought and 1 that the restore was successful. Check this question I have answered recently for sample code. Restore Purchase : Non-Consumable
"We found that your app offers In-App Purchase/s that can be restored but it does not include a "Restore" feature to allow users to restore the previously purchased In-App Purchase/s. To restore previously purchased In-App Purchase products, it would be appropriate to provide a "Restore" button and initiate the restore process when the "Restore" button is tapped"
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.
guys I've implemented an in-app purchase using PARSE. Now there is no restore button in my app . My DB, hosted on the PARSE cloud has a an attribute called "hasMadePurchase" in my User's table which is checked every time the user tries to make a purchase. The attribute is set to yes as soon as a successful purchase has been made.
Now with that, do I need a restore purchases button for the app to get it through the app store? Cause clearly, even if the user changes his/her device deletes and re-installs the app or whatever he/she will still be able to get all his/her purchases back.
If yes, than what do I need to implement in my restore function? (which would basically do nothing, other than making fake calls, i don't know i am kinda lost)
A restore purchases button is needed only if the app offers non-consumable IAPs, e.g. unlocking content. Our game got rejected recently exactly for this reason - we were offering weapon unlocks and we were missing the restore purchases button.
If you are offering non-consumable IAPs then you can start by looking into [[SKPaymentQueue defaultQueue] restoreCompletedTransactions] and go from there. Basically, this fetches the list of all IAP SKUs that have been previously purchased by the user.
When a user of an iOS app purchases a non-consumable item, then installs that app on a new device, it is possible for them to again go through the standard purchasing logic for that item. The app store will ask them if they wish to spend $0.99 on the item, but if they click "Yes", it will inform that they already own that item, and ask if they wish to download it for free.
I would like to track new purchases in my analytics, and not have them conflated with re-purchased items that a user receives for free. Unfortunately, it seems that this behavior is indistinguishable from a genuinely new purchase, (to the client app). Apple seems to say as much: "Note: If the user attempts to purchase a product that’s already been purchased, rather than using your app’s restoration interface, the App Store creates a regular transaction instead of a restore transaction. The user isn’t charged again for the product. Treat these transactions the exact same way you treated the original transactions."
In discussing this issue, most posts (and Apple's documentation) say that I should offer a 'Restore Transactions' button to the users. I do offer this button, but it is always possible for users to circumvent this logic, and go through the traditional purchasing route. This is where my tracking will become inaccurate.
Do I have any options? Thanks!
I am pretty sure you don't have any options for tracking a new purchase versus downloading a previous purchase for free when a user does an in app purchase. I have looked into this for the same reason of analytics and I could not find a way to do it. IAP is set up to make sure that you honor purchases made by the same iTunes account on other devices.
If your users are required to have an account specific to your app to make a purchase you could use that to know if they already have made the purchase or not. But requiring an account for purchase can lower your conversion rate.