8

Possible Duplicate:
Is there a clock in iOS that can be used that cannot be changed by the user

I know in many iOS games that have tasks that take time (i.e. "10 hours until animal done breeding"), one can go into "Settings" and change the time to speed up the completion of the task. In the game I'm developing, I don't want users to do this, so I'm trying to implement a system to prevent this type of cheating. I've put a lot of thought into this, but can't come up with a solution. Basically, my question is how do I keep track of time without relying on the system clock (which can easily be manipulated) for the purpose of preventing users from cheating?

Community
  • 1
  • 1
pasawaya
  • 11,515
  • 7
  • 53
  • 92
  • 9
    query a time server and don't rely on local device – sdolgy Aug 25 '12 at 06:50
  • 2
    +1 for the question that Adobe and Microsoft have been asking themselves for years for unlicensed product usage prevention. – Mick MacCallum Aug 25 '12 at 07:14
  • 1
    So you don't want to rely on the local clock, but you have unreliable connection to the net? You can't have your cake and eat it too, you know... :-| – Pranav Hosangadi Aug 25 '12 at 07:28
  • @sdolgy - The more I think about it, the more I realize the genius of your solution. One application that doesn't allow cheating is DragonVale, and they require an internet connection to open the app. This fits in with your answer, as if I require an internet connection to open the app, then whenever it opens, I could query the time server. The thing is, I'm not very familiar with networking, so how would I go about "querying a time server"? – pasawaya Aug 25 '12 at 07:33
  • You can find a list of time servers [here](http://tf.nist.gov/tf-cgi/servers.cgi) – Pranav Hosangadi Aug 25 '12 at 07:35
  • @PranavHosangadi - Some of the servers say "Temporarily Unavailable". Are there more reliable time servers, because if a time server that my app relies on is down, then the user can't play. – pasawaya Aug 25 '12 at 07:37
  • 1
    Well, you should just query the generic time.nist.gov , which will then distribute the load between the other servers automatically. I would have thought you read the contents of that page before commenting :P – Pranav Hosangadi Aug 25 '12 at 07:40
  • @PranavHosangadi - Sorry. I did read that, but I misunderstood the fact that all the servers were relaying the same time; some servers were west coast and some east, so I mistakenly thought that the different time servers would respond with different times depending on their location. Thanks. – pasawaya Aug 25 '12 at 07:41
  • Could you compare the change in system time and uptime between app suspend/resume cycles to verify the clock? I don't know if uptime is affected by system time changes, but hopefully it isn't. – nielsbot Aug 25 '12 at 07:49
  • @nielsbot That's a really good idea, of course assuming uptime isn't affected. – Mick MacCallum Aug 25 '12 at 08:11
  • 1
    @nielsbot, I don't think that's reliable... if they legitimately cycle the device, the app will be killed/terminated and the user can change the clock before restarting the app. – EthanB Aug 25 '12 at 09:07
  • see also http://stackoverflow.com/questions/11413616/is-there-a-clock-in-ios-that-can-be-used-that-cannot-be-changed-by-the-user – nielsbot Aug 25 '12 at 20:47

2 Answers2

3

transforming my comment into an answer.

Instead of relying on a user or device, rely on an external source for providing unbiased time. A time server, your server, etc. If you don't trust....

sdolgy
  • 6,963
  • 3
  • 41
  • 61
1

Instead of "X hours of real-world time", would "Y minutes of in-app time" work for you? You can pause/continue a timer when your app suspends/resumes.

EthanB
  • 4,239
  • 1
  • 28
  • 46
  • That's a good suggestion, but I want tasks that take time in my game to continue even when the app isn't open. – pasawaya Aug 25 '12 at 17:29
  • OK. You'll probably have to use a time server -- either your own or a public. (Or not care and let them fake it if they want to...?) – EthanB Aug 26 '12 at 00:47