I’m trying to build an iPhone app that uses a virtual coin system. The user buys coins and then uses them in the game. How do I keep track of the number of coins they have used.
If I store the info locally, can’t someone just go in and alter the file and then up the number of coins. Is it possible to prevent that on a jailbroken phone?
Is there a way to store the number of coins on a database without having them register.
Oh but yes he can.
No, not really. However, that can’t be done without a jailbreak (the applications are installed out of the programmatically accessible jailed root of iOS’ filesystem, which is constrained to the /var/mobile/Media library – applications downloaded from the AppStore are installed in /var/mobile/Applications) – so regarding 90% of your users, you’ll be safe.
You can use in-app purchases or just auto-register their device ID (the serial number, the MAC address, a hash generated from them similar to the now-deprecated UDID, or just a simple UUID) with your server and store the “money” online. In both cases, it is recommended that you verify each and every transaction with your own server, else it can be tweaked (literally; google iAPCracker).