How to create a daily reward/bonus feature?

Does Nakama support Daily reward/bonus in unity and if support is there any documentation/ reference?

Hey @Raja_Nukala welcome :wave:

Does Nakama support Daily reward/bonus in unity and if support is there any documentation/ reference?

Nakama can do daily reward/bonus feature easily but because it’s quite straightforward to do there’s no built in API for it. I can describe how you can achieve it:

  1. Decide on what rewards you want to make available to players and create a JSON file you can upload to the server in the devconsole to create a storage object that is owned by the system user. I’ve created a small example for now:

    [
        {
            "collection": "datasets",
            "key": "allRewards",
            "user_id": "00000000-0000-0000-0000-000000000000",
            "value": "{\"available_rewards\": [{ \"name\": \"day1\", \"value\": 100 }]}",
            "permission_read": 2,
            "permission_write": 0
        }
    ]
    
  2. Now that the storage object for the available rewards is setup you can create an RPC function that will be called by the game client at each app start. Have a read about RPC functions here.

  3. Your RPC function would check for a timestamp that you’d store somewhere for each player (probably in the user’s metadata). Then fetch the available rewards if the time difference between current time and the last timestamp meets the threshold for the reward. Issue the reward to the player and set the timestamp to the current time.

There’s a lot more advanced capabilities you can add to your code to fit the game design you have but this is the basic outline on how to achieve it.

Hope this helps.

1 Like

Thank you replay. I will try.