I want to add player economy and send message with pushclient to the player when a player interact with my website. But in the API doc for calling cloud code module there isn’t a way to inject IExecutionContext to the cloud code .
Another way I can think of is calling economy and push message directly via API but I cannot find Web API for the push message (not push notification). Is there any way to achieve this behaviour?
Thanks in advance!
[CloudCodeFunction("AddRewardFromExt")]
public async Task AddRewardFromExt(IExecutionContext ctx, long amount)
{
try
{
CurrencyModifyBalanceRequest balreq = new CurrencyModifyBalanceRequest("GOLD", amount);
await _gameApiClient.EconomyCurrencies.IncrementPlayerCurrencyBalanceAsync(ctx, ctx.ServiceToken, ctx.ProjectId, ctx.PlayerId, "GOLD", balreq);
var res = await _pushClient.SendPlayerMessageAsync(ctx, $"Reward#{amount}", "Reward", ctx.PlayerId);
}
catch (Exception ex)
{
_logger.LogError($"Failed to AddRewardFromExt. Error: {ex}", ex.Message);
}
}