Reputation: 2768
I created an app that gives the user 3 coins at the first launch.
Once the user finished the 3 coins he should buy unlimited coins by an In-App purchase.
The problem is that if the user doesn't want to buy unlimited coins he can delete the app, install the app again and he will have again the 3 coins again.
And he can do this forever without ever buying the In-App purchase.
Is there a simple way to prevent this? How can I know if a user finished the coins inside the app even after deleting it?
Upvotes: 2
Views: 574
Reputation: 4375
You can handle this problem in a two different way.
Approach 1: Store identifer in the KeyChain
You will lose this keychain data, if user reset their device.
After reset the device you will provide the coins again because your flag/identifier will not be there in the keychain.
If you want avoid this situation then you have to go with the second approach.
Approach 2: Store identifier on the server
Instead of storing the details on the device keychain. You have to save it on your server. App first launch you have to check with your server to provide the details.
This approach always works even user reset their device
Upvotes: 2
Reputation: 4466
You can get unique device id from device keychain and save to server and after App first launch you have to check this unique device id is already available to your server or not.
I am using Keychain library to have an easy access to app keychain.
You can use the below method to get and check unique device id
// MARK: - Get UUID from keychain because delete app and reintall changes the UUID.
class var getUniqueDeviceIdentifierAsString : String {
let appname = Bundle.main.infoDictionary![kCFBundleNameKey as String] as! String
var strApplicationUUID: String? = KeychainWrapper.standard.string(forKey: appname)
if strApplicationUUID == nil {
strApplicationUUID = UIDevice.current.identifierForVendor?.uuidString
_ = KeychainWrapper.standard.set(strApplicationUUID!, forKey: appname)
}
return strApplicationUUID!
}
Upvotes: 1
Reputation: 622
Any local DB, SQLite, Core Data, File Archiving, plist won't survive if app is deleted. There are three ways to get persisted data after app reinstall on iOS:
- Saving the data on server. But this case will only work if user is always logged into account.
- Using Keychain to store the data. There are good Keychain implementations like
JNKeychain
- Using iCloud. Implementing CloudKit in your app will enable you to save data corresponding to the iCloud user which can be retrieved later on reinstallation.
Upvotes: 0
Reputation: 1895
One solution is to use Keychain storage of your device. But if user login to some other device then this problem will still exist. You can use iCloud keychain storage for this or store the necessary parameters on the server. Using iCloud keychain is very easy and reliable
Upvotes: 0
Reputation: 3405
User can store the value in the keychain of the device. you can save that data in keychain untill he reset all settings in the phone. I normally uses this library to store data using keychain.
But its better to keep the status in server using a webservice because even if you stored data in keychain, user can reset all settings of the device and install app again which gives him 3 coins again. Without a back end support its not possible to do a perfect solution for this
Upvotes: 0
Reputation: 315
There are a few ways to implement it:
Use Keychain to store coins count. Any other local storage is less secure and will not "survive" app deletion. I'm using KeychainAccess library to have an easy access to app keychain.
Store user profile with coins count on your server. Also you could validate each In-App Purchase and validate any coin consume operation to protect from IAP Hack tools, Main-in-the-Middle attacks on user profile sync, etc.
Upvotes: 0