View as Markdown

Reward mailbox

The reward mailbox holds rewards for a player to claim later. For how it works, see Reward Mailbox. For a team’s shared mailbox, see Teams.

Initializing the reward mailbox system #

The reward mailbox system relies on the Nakama System and an ILogger. Pass both to the constructor:

1
2
var rewardMailboxSystem = new RewardMailboxSystem(logger, nakamaSystem);
systems.Add(rewardMailboxSystem);

The Nakama System must be initialized first. Otherwise, initializing the reward mailbox system throws an InvalidOperationException.

Listing mailbox entries #

List the rewards in the player’s mailbox. Results are paginated: pass the returned Cursor to get the next page.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
var mailbox = await rewardMailboxSystem.ListAsync(100, "");

foreach (var entry in mailbox.Entries)
{
    Debug.Log($"{entry.Id}: can claim {entry.CanClaim}, expires {entry.ExpiryTimeSec}");
}

if (!string.IsNullOrEmpty(mailbox.Cursor))
{
    var nextPage = await rewardMailboxSystem.ListAsync(100, mailbox.Cursor);
}

Claiming a reward #

Claim a reward by its entry ID. Set delete to true to remove the entry from the mailbox after it’s claimed:

1
2
var claimed = await rewardMailboxSystem.ClaimAsync(entryId, true);
Debug.Log($"Claimed {claimed.Id} at {claimed.ClaimTimeSec}");

Deleting mailbox entries #

Delete one or more entries without claiming them:

1
await rewardMailboxSystem.DeleteAsync(new[] { entryId });

The mailbox entry object #

AttributeTypeDefinition
IdstringUnique identifier for this mailbox entry
RewardRewardReward object containing currencies, items, and other assets
CreateTimeSeclongUnix timestamp when this entry was created
UpdateTimeSeclongUnix timestamp when this entry was last modified
ExpiryTimeSeclongUnix timestamp when this entry expires and becomes invalid
ClaimTimeSeclongUnix timestamp when this entry was claimed, 0 if unclaimed
CanClaimboolWhether this entry’s reward can currently be claimed