For each player, they have a chance 1% to receive reward per hour.
They’ll get push notification if they are offline.
I created a cloud code module, but I don’t know how to run the module each hour.
In addition, when not triggered from game client, how do I know playerId. I think IExecutionContext just work when I call from game client.
[CloudCodeFunction("GiveReward")]
public async Task GiveReward(IExecutionContext context, IGameApiClient gameApiClient)
{}
You could setup an hourly Cloud Code schedule which calls out to the Authentication Admin API to list a number of players. You could then give a subset of those players a reward in Cloud Save/Economy.
Some caveats:
- You would need to make sure execution does not take longer than 15 seconds
- Our Push Notification service only supports sending to Analytics Audiences so you would not be able to call it from Cloud Code. You could call an external service like OneSignal from Cloud Code for this though