How do I maintain state of in app purchase across devices and restores - iphone

I am trying to implement in app purchase for an iOS application
Did some googling and read this thread : Maintaining records of iOS in-app-purchases
It seems the way to go indicated is to use keychain
My in app purchase type is - Non-Consumables
Am wondering what is the best strategy for :
1
If a user has made an in-app purchase and resets the phone / deletes the app and then again downloads the app - do not want the user to pay up again
2
if the user does an in app purchase on an iPhone and then does an update on the iPad - he should get the in app purchase content without paying again
As far as possible do not want to store anything on my server if at all possible and am sure storing something locally on the device is useless for resets / multiple devices
Thanks!
akila

Apple keeps a record of what the user has purchased.
You also must implement a in app purchase restore button for the user in case of the two situations you mentioned above.
The inapp purchase restore button asks the App Store if the user has purchased before and sends you authorization if the have.
I recommend you use a library like RMStore on github to deal with in app purchases, the only big manual thing you need to do is obfuscate the in app purchase status as it stores it in the NSDefaults.

If a user has made an in-app purchase and resets the phone / deletes the app and then again downloads the app.... you want to restore the transactions by keeping an Restore button . Once you click on the restore button you want to connect with the storekit for restore the transactions. Their you can get the list of products that user has already purchased . Check the list of productids if your productid is match then unlock the content. All the best

Related

Paid App : need to uniquely ID the user

I am designing a paying app that will require users to create their own profile.
This app will of course be downloadable on each of the devices the user has.
This is the precise scenario I want to bypass :
the user downloads the App on an iPhone
he creates an account and start using the app that makes server
calls
he downloads the app on his iPad and with his login & password
retreives the data on the server, so far so good
Now, he lends his iPad to a friend (who didn't pay for the app).
The friend wants to use the App, and wants to create his own
account. Yet, I want to forbide this since he didn't pay for the
App.
So my problem is : I want to restrict the use of the app only to the user that paid for the App, not for his friend.
Of course, I cannot use the AppleID since there is no way to reach it from code.
I thought one moment that I could use iCloud like mentioned here but since the ( iOS unique user identifier )user can choose not to use iCloud, my problem is not solved ...
Is there an easy solution that I missed to solve that issue?
You friend will be using different apple id. You could use Restoring Transactions api of apple to get understand whether the user has purchased the app or not. This is possible for non-consumable in app purchase. Please do check the below link :
https://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/MakingaPurchase/MakingaPurchase.html#//apple_ref/doc/uid/TP40008267-CH3-SW1

Using a non-consumable in-App purchase with ID's

I'm using in-App purchases in my App on behave of getting some sounds from the App to the iPhone as a ringtone.
I've used 'Consumable' as the type for in-App purchase so that the user would be able to buy a ringtone and download it directly.
However this App got rejected by Apple because they want this function to be non-Consumable (so you would be able to retrieve this ringtone more than once). I only don't know how to set this up in my App because there are more than 200 possible ringtones. The actual buying is not the difficult part but as a criteria for in-App purchases you need to be able to restore previous transactions. As I'm only using one product identifier I think I would not be able to identify which ringtone has been purchases when restoring.
So my final questions:
1. How can I identify which item is bought (i.e. by using tags in the purchase)?
2. Am I able to use only 1 product identifier for this In-App purchase. Or do I need to make a productIdentifier for each and every ringtone?
You have to create a non-Consumable product for each ringtone, each one with a different identifier, if Apple is refusing your app I think you have no other choice.

Restore Purchases button for In App Purchases stored on website?

Is a Restore Purchases button that calls restoreCompletedTransactions needed for In App Purchased consumables and non-auto renewable subscriptions if the current user's count of these purchases is stored and retrieved from a website?
I'm thinking the Restore Purchases button is not needed in this case. In my app whenever the user wants to use an In App Purchased consumable or subscription, the app contacts the website and downloads the user's current count of the In App Purchased consumable/subscription. These In App Purchased products can only be used with internet connectivity, so if there is no Internet access, then the user can't use the In App Purchased consumable/subscription.
I understand the case where a user has multiple devices and has In App Purchased consumable/subscriptions that were purchased on one device and wants to use these products on another device, but that is not the case I am asking about here.
Is a Restore Purchases button needed where the In App Purchased items are stored on a website and the In App Purchased items are used on the same device that they were purchased on?
I think,that if you store all the history of user purchases,and you will let him use all the purchases he made right when he wants it,there is no need for an extra Restore button in your app.

Paid app to Free app with Inapp purchase

I have my paid app in appstore now I am converting it to a free app with inapp purchase. and i want to give the data free for the user's who purchased my Version 1.0. At this point I am facing a problem. If the user buys my paid app and if he deletes the app after sometime before I release my update what should I do in this case I want to give the data for free for the user's who deleted the app also. I have two questions here
1) Will my app gets approved even If I don't give the data for free for the users who deleted the application and doesn't have any backup of my app ?
2) If it is possible to give the data for free for the user's who deleted the app please tell me the way how to do it?
You can not do anything if the user delete the app from device and install your latest in app purchase version. If your application is interacting with your server and storing information about the user who purchased the app, means it depend of your app functionality. If your app is social networking app any login/ registration is there inside your app and that registration of user you are storing on your server then you can allow free access of your app based on the registration mail id of that user.
Secondly, if you have any database sqllite inside your application then you can allow free access of your users based on that database.What you can do is on your latest release change the name of hat database and when your application start then you can check if previously database exist already if yes that means that is old user and you can allow that user free access of your content.Plese note that if user delete the app before installing your latest version then in that case we can not do anything and another a case is that
if user install his app on another iPad then in that case also we can not do anything. Now answer to your questions:- 1. yes your app gets approved by apple whether or not you are giving content free to old user apple did not care of that. 2. we can not do anything if user delete the app before installing your latest version of app until and unless your app has some interaction with your server.Let me know if you have any other questions

Adding in app purchases with purchase automatically turned on for some users

I want to revamp the purchase model on one of my iphone apps to use in app purchasing to unlock the full featured app instead of having two separate apps. Is there a way to do this so that anyone who has previously purchases the app can get the purchase for free automatically?
The strategy that I used is to create a NSUserDefaults for previous purchasers of the application. Then I put that version in the app store for a month. I picked a month so that hopefully that all users had a chance to up date the app. After a month I put the in app purchase feature into the app and put that in the app store.
When I test to if I should use any in app purchase content I also check to see if the NSUserDetaults I created in the previous version is set.
There is not currently any way for the user to be given the In-App Purchase item for free.
However, if you can detect that the user upgraded from the old version (e.g. by examining NSUserDefaults) you can easily enough have your "did they purchase the full version?" check return true for that case too.