Migrating from paid app to in app purchases iOS - ios

Currently i have a paid app, i store no information in NSUserDefaults or keychain in order to identify that user has paid, and i dont want to release an update just to do that..
Now i want to use IAP, and considering the above the only way i can find out if user has already bought the app(version prior to IAP) is through purchase receipt validation, and i would like that to be done locally.
Any ideas how it can be done in swift?
Please don't mark this as duplicate, i have already read other similar posts..
If you can think of any other solution, other than purchase receipt validation, that wouldn't require an interim update please advice..

Related

In app purchase query

I am working on in app purchase which works fine but I want to know that user have purchased product or not at the launching time of application.
How should I know this.
If anybody knows please help.
Thanks in advance.
You can store a "receipt" in the user defaults (NSUserDefaults) then check if the receipt exists when the app is launched.
HOWEVER plainly using NSUserDefaults is prone to hacking so you can use a secure version of user defaults from here.
another solution (and the recommended one if done correctly) will be to store receipts on a server and read available receipts when the app launches. (Note though that if the user has turned device data off you won't be able to read them).
It would be best to get the user's purchase receipt and check all the products they have purchased.
You can follow the guide here to see how you can validate receipts locally.
This document explains the structure of the receipt - the in-app purchase fields have the product identifiers which can be used to find out which IAPs the user has access to.

Upgrade paid app to free app with in app purchase

Im going to add a new version of my on app store. The earlier version was paid. The current app will be free with inApp purchase. I don’t want previous user upgrade to new version and they have to pay again for various products that were already present in previous version. Is there any way to check if the user had purchased the previous version of the app.
Don't you have the list of those users in your database? If you have then set condition that, they won't need to update application(for those specific users only).
I will also update my app from paid to free with in-app purchases and had the same thing in mind. I am using the RMStore library to check the originalAppVersion of the App Store Receipt and unlock features of my app accordingly.
This related thread and the RMStore wiki provide the needed information.
Note that the receipt may not be stored on your device (at least while developing, I noticed), so you may need to refresh the receipt using [RMStore defaultStore] refreshReceiptOnSuccess:^{} failure:^(NSError *error){}];

Merge paid app and free app with in app purchase

I have 2 application on appstore
Free app with in app purchase.
Paid app.
Now, I want to keep only one app on appstore from above options 1.Free app with in app purchase and remove the paid app. But here I want to give the app with full functionality to those user who used the paid app (Purchased the paid app).
Here my question is how can I merge these 2 app into single app which will be free and contains in app purchase by keeping the paid app user as it is ?
If anyone have any idea regarding this then please share.
Thanks in advance.
I solved my problem by using the icloud. First I provided the update to both the application by doing following changes.
I used "key value store" icloud option and stored some setting on icloud just need to make sure here "iCloud Key-Value Store" value in .entitlements file (which was automatically created by XCode) in both the application is same for both the application. The setting stored here is accessible to both application and depending on the setting I identified the user and gave access to specific functionality.
Under iOS7, you can use Receipt Validation. Receipt Validation offers you to see information about purchasing the app and in app purchases. If it returns date before you made the app free, that means that the user paid for the app.
This will work only under iOS7.
See Receipt Validation Programming Guide
I too am facing this issue with a couple of my apps. I'm still looking for a good solution, but I came up a less-than-ideal solution in the meantime. You can issue an update to your paid app that will connect to a database (on your web server) and insert a row with information about the purchase (AppleID, maybe some kind of digital receipt). Then in the free version with IAPs, the same database connection can be used to see if the owner of the free app already purchased the other app. Based off of that, you can unlock the IAPs. The only problem is that this is dependent on all previous customers updating to the latest version.
As mentioned, Receipt Validation would probably be more efficient, however this isn't backwards compatible. Good luck!
I'm assuming you're looking to merge the purchase history on Apple's servers; you can't merge the purchase data for two bundle IDs, you'll have to devise some way of having users persist their data on a server that you control. Update your app with a login and tie that login with the purchases as user has made.
The workflow would be something like this:
1) User logs in on paid app
2) User restores purchase history
3) Paid app saves restored purchase history to your server
4) User logs in on free app
5) Free app downloads all purchase data for the logged in user

iOS In-App Purchase No Back-end

I am investigating the use of in-app purchase for what essentially would be a "pro" version of my app.
The app itself would be free but once in the user has the option to purchase the pro content (only 1 thing). The "pro" content would already be on the app and there is no need to download it, it would simply "unlock" it.
Is this allowed from the Apple Guidelines?
As only 1 non-consumable would be purchased I think the use of a back-end server isn't required.
Again is that allowed from the guidelines?
And is it safe and simple to just store the result in NSUserDefaults and if installed on another device pull it from SKPayment restore purchased and such?
I've looked at several other questions.
In-App Purchasing?
Retrieve purchased information in In-App purchase
How do I add consumable In App Purchases using NSUserDefaults and not my own server?
And those seem to suggest that my approach is valid, but as I know those things have changed recently I want to make sure I'm taking the right approach.
Thanks!
No problem having the content built in.
Best practice is to perform receipt verification on a server with an authentication protocol between the app and server (this is also true for several other mobile app stores). If you perform the verification on the device, people can use existing tools to get around your IAP checking and steal content. Take a look at https://developer.apple.com/library/ios/#releasenotes/StoreKit/IAP_ReceiptValidation/ for some information.
So while a server is not required, it is recommended. Only you can say if protecting your content is worth the hassle of maintaining a server.
I agree with J. Freeman that straight storage in NSUserDefaults seems weak. I store things in a local file but the format is tied to the device and requires a server computed key to create it. Finally, yes you should use SKPaymentQueue restoreCompletedTransactions to get things purchased on another device. Realize that the restored transactions should also have their receipts verified on your server.
Yes that is fine. You do not need a backend to do in-app purchases, and it is ok to ship with your content built in.
The one thing I would say be careful with though is storing the unlock information in NSUserDefaults as someone will easily be able to forge purchases that way. You should store the unlock information in the keychain.

iOS in-app purchases - best way to tell if user has purchased

I need to set a global variable when a user makes an in-app purchase. I could use NSUserDefaults, and just have a key called "Purchased", but that doesn't seem very secure.
What is the best way to securely store data so that I know whether or not users have made a purchase?
For example in a particular view I need to know whether or not to display a "Purchase" button. Obviously it should be hidden if they've already made the purchase.
For secure data you should use the iOS keychain. Here's the documentation:
http://developer.apple.com/library/mac/#documentation/Security/Conceptual/keychainServConcepts/iPhoneTasks/iPhoneTasks.html
Hope this helps.
There is no need to store that information. There is a method to restore all the user purchases. Look for restoreCompletedTransactions.
You can check all the user's purchases in your view and then show the "Purchase" button for all the items that can still be bought.
UPDATE:
Oh! I misunderstood your question. The above method will get you the purchases the user has made in case of an app reinstall for instance. Regarding your question, it is completely fine to store information relative to the purchased products in NSUserDefaults to give the user the goods, levels or whatever he has paid for.
I recommend this step by step tutorial that helped me implement in-app purchases to answer all your questions.

Resources