Hi, I’m developing game in which I give free gifts to players every 3 hours.
For this I’m using System.DateTime and System.TimeSpan classes. All is working good except one thing: player can change data time in his iPhone/iPad and get gifts every minute, because algorithm thinks 3 hours interval was passed.
I check this situation in few Unity games (for example, Crossy Road) and some how they managed this problem: system time doesn’t affect calculation of free gift interval.
Maybe someone know how? The only idea is they are using Push Notifications, perhaps this is the key to calculate time?
Thanks. The idea with server is clear.
But, I check how Crossy Road and Sling Kong behave without internet connection (in Airplain Mode) and discover next: they still able to calculate time intervals correctly.
When I read an article about Android Push Notifications, it was mentioned, that push notifications is like a separate thread and can work all time even when App is closed. Maybe iOS Push Notifications works same way? Maybe it’s possible to run a daemon process wich could calculate time?
Also is’t good to save last date when player collects gift, and if current date is less than saved - most probably this is a cheat: player sets date in future, come to game, collect gifts, closes game, returns to real date. Of course this is no a 100% guarantee, but it forces player to do more iterations to achieve “cheat gifts”.
As BoredMormon said, you have to fake if the user has not internet.
Every 3 hours, locally on the device (timer based on current phone time), trigger a function
In this function :
First, try to reach your server
If internet is enabled, you can calculate the gift like I said in my previous post
Second, if internet IS NOT reachable OR (internet is reachable AND gift has been gave)
Emit a local notification
If the player change his local time, a notification will be send, but when internet will be available the server will say ‘hey man, it’s not true !’. So you’re good