1

I have a game where users can do a certain activity once per hour. How can I make sure it's been an hour since the last time they attempted something without them just changing their devices current time in settings?

Also, if I wanted to prevent the user from just deleting the app and re-installing it so they could constantly keep trying without having to wait to full hour is there any way I can store data on the device even after an app delete or would that have to be a server thing?

If I don't have a server can anyone think of a clever way to do this via Free in-app purchases or something?

user229044
  • 232,980
  • 40
  • 330
  • 338
Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195
  • you can store something in iCloud – dthien Feb 15 '13 at 04:24
  • 1
    @dthien iCloud is a sync service. If you delete an application off the device it deletes the application's associated data. The deletion would get synced to iCloud, which would also remove the data. – Jack Lawrence Feb 15 '13 at 04:25
  • 1
    Cheaters will always cheat. If it is just a game, I would not loose too much sleep about it. – vonbrand Feb 15 '13 at 04:46
  • Just thought I'd add my own question here: Are you implementing this "once per hour" limitation because it makes the game better, or because other games do it too? – Eric Feb 15 '13 at 14:05
  • Well, I don't play other games so I don't know _if_ other games do it or not. I'm doing it as a business strategy, not as something to make the game more appealing... I want to stimulate word-of-mouth and drawing users back as often as possible is the best method to do so. In all honesty, it's not _actually_ for a game, I just thought that would make the best example. – Albert Renshaw Feb 15 '13 at 16:56
  • @Eric , sorry I forgot to "@" you in that last comment! – Albert Renshaw Feb 16 '13 at 04:07
  • @AlbertRenshaw It's a pretty common feature among social media games (Farmville, etc). It lures the user into making the game part of their daily routine by rewarding them for checking in throughout the day. And according to the numbers, it works pretty well. – Eric Feb 16 '13 at 06:05
  • @Eric , great! I'm hoping it will work for me as well then! I do know with Farmville they require you to come back at certain times... my app simply disables a feature for a given period of time, you aren't required to come back though, I think that hinders the user experience. – Albert Renshaw Feb 16 '13 at 13:39
  • [Do not use signatures, salutations or taglines in your posts](http://stackoverflow.com/faq) – user229044 Mar 14 '15 at 13:37

2 Answers2

4

The only way to persist data in a way that survives app reinstalls is to save it to the keychain. This works, because keychain data may be shared across multiple applications; the rest of your application's data is removed on uninstall.

If you need a reliable way to tell the current time, the device must be connected to the internet. In this case you would be able to check the current time using one of the time services through the NTP.

Community
  • 1
  • 1
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
  • Followup question: Do you know how much data is allowed to be stored in the Keychain? – Albert Renshaw Feb 15 '13 at 17:02
  • 1
    @AlbertRenshaw The closest thing to an answer that I was able to find is [this](http://stackoverflow.com/a/13488926/335858), but I strongly suspect that it is OS-dependent. It should be sufficient for a single date, though. – Sergey Kalinichenko Feb 15 '13 at 17:06
2

That sounds like exactly the sort of task you would need a server for.

When the user wants to perform this limited action, have them ask the server for permission. You can log the user's ID and request time, decide if they can execute the action, then return a small success/failure message. Works if they change their clock, works if they log in from a different device, works if they wipe the device data.

Eric
  • 6,965
  • 26
  • 32