api for daily reward?

which is the correct code for daily reward on games?

Depends on your objectives.

The simplest way would simply to be to check the current date with System.DateTime.Now

Usually for something like daily rewards, you’d access a server to get a server datetime and then save it out the first time they log in. Then the next time, you’d get a datetime again and compare if it’s the next day or just a day after the first day. (depending on if you want them to log in daily).

Now, if you don’t care that they could try to do something different, you can use device time as well. Or if you don’t have a backend service or server that you are using to store data. Which is what @Kiwasi is suggesting.

1 Like

This makes sense if you are concerned about cheating.

For a single player game, providing consistent rewards for your player base regardless of their online state is important. Players that cheat in single player are also likely to bypass your monetisation strategy as well. So they aren’t your important audience.

But for anything multiplayer preventing cheating via a server is critical.