DanielZanchi
DanielZanchi

Reputation: 2768

Limit iOS App even after the user re-installs it

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

Answers (6)

Subramanian P
Subramanian P

Reputation: 4375

You can handle this problem in a two different way.

Approach 1: Store identifer in the KeyChain

  1. First check the value from keychain if the user already installed the app on this device or not.
  2. If it is first time install then provide the free coins and store the user id/flag in the keychain to identify future install.

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

Nikhlesh Bagdiya
Nikhlesh Bagdiya

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

iSaalis
iSaalis

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:

  1. Saving the data on server. But this case will only work if user is always logged into account.
  2. Using Keychain to store the data. There are good Keychain implementations like JNKeychain
  3. 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

iOS_MIB
iOS_MIB

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

Amal T S
Amal T S

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

Krin-San
Krin-San

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

Related Questions