Time cheating preventing for IOS & Android

Did someone have experience with protecting application from time change in cocos2d-x C++ for IOS & Android?

Like you have some coldown timer for spell, but if you set time in future you get this item immediately. Is there any example to protect from following cheating in offline mode.

I know that it possible to make requests to server and save/retrieve timer, but if user is offline how to do this.

I always used SQLite and stored the correct timing for things like this and then checked it against the system clock to see.

What’s the probability, that a user is online? If a user wants to buy stuff with real value or your game wants to show new non-cached ads, your game also needs an online connecting. I don’t see a problem with always on.

If you really want to prevent offline cheating, you need to get the time from a monotonic clock. Many VC versions are buggy and do not provide monotonic clocks. This is against the standard, so you have to test your compiler/runtime or switch to a conforming one.

Take a read about it here:

If your system clock is not monotonic, it wouldn’t help, as you are just storing the start time and compare it to the system clock, right? Do you get the system time through SQLite? Is it monotonic?

My solution is to get time from sntp server pool. Only downside is that user needs to have internet connection.

Just use a monotonic clock and you are safe.