Time based Item Regeneration (even when app is closed)


I am making a game where you need to have a GameSlip to play a level of the game. There are 2 ways to get these GameSlips. One way (which is done) is by purchasing it through in-app purchase and the other way (where I need your help) is that the GameSlip gets regenerated after a certain time period.

Now I can do this when my app is running … but how should I regenerate my GameSlip when the Game/App is closed?

What i do is i save in PlayerPrefs time when it should be regenerated, or the start time when it was lost(and add to it regeneration time), and when game opens you can just check that Time. You can use DateTime.Now for this or find some(or create) some service that will return current time from the internet. (Also, depending on the platform, its nice to send notifications that GameSlips are regenerated).

Ok there are many ways to achieve this, one of being;
use the system clock, this is dangerous because they can change the clock, from the system clock it can use the time and specified times to compare and therefore making it able to work. good article on getting the time: http://forum.unity3d.com/threads/how-to-get-system-time-in-unity.29667/
use a server, this server can contain the time, this is a good idea because it is less *cheating- proof. The only problem is that you have to set up networks and a server.
search up some.

I hope I helped you!
-Cow Necromancer

you can try OnTick, its a system that uses timers and ticks (milliseconds) Although I don’t know how well it will work if the device is not actually on. You would have to test that out if you were to use this kind of system, I would only use it with say, server times as well.