Skip to main content
Version: 6.0.0

ReadPlayerMail(User)

public BackndReturnObject ReadPlayerMail(string postIndate);

Parameters

ValueTypeDescription
postIndatestringinDate of the mail from which items were received

Description

Claims one piece of mail using its indate.
The return value for admin, ranking, and coupon mail are all the same when claimed. Different return values are provided for user PlayerMail.

  • The data types "S", "L", and "M" in the return values of the previous mail function(Backnd.Player.Post) was removed.
  • Even if indate exists, you cannot claim the mail if it is a different MailType.
  • The mail is not automatically deleted after being claimed. Call the DeleteUserPost method to delete it.
  • You cannot claim expired PlayerMail.
  • Information of the received item will not be inserted/modified in the user's DB automatically, so you must update it manually to the recipient's game information in the client.

Example

Synchronous


//Load mail list
BackndReturnObject bro = Backnd.PlayerMail.GetPlayerMailList(type, limit);
BACKND.LitJson.JsonData json = bro.GetReturnValuetoJSON()["postItems"];

//Get the inDate of the 0th mail in the mail list
string recentPostIndate = json[0]["inDate"].ToString();

// Claim mail with the same MailType
Backnd.PlayerMail.ReadPlayerMail(type, recentPostIndate);

Asynchronous

// Mail type
MailType type = MailType.User;

//Load mail list
Backnd.PlayerMail.GetPlayerMailList(type, limit, callback => {
BACKND.LitJson.JsonData json = callback.GetReturnValuetoJSON()["postItems"];

//Get the inDate of the 0th mail in the mail list
string recentPostIndate = json[0]["inDate"].ToString();

// Claim mail
Backnd.PlayerMail.ReadPlayerMail(type, recentPostIndate, callback2 => {
if(callback2.IsSuccess()) {
Debug.Log("Successfully claimed the PlayerMail.");
}
});
});

Return cases

Success cases

When the mail is claimed successfully
statusCode : 200

returnValue : refer to GetReturnValuetoJSON

Error cases

When a non-existent postIndate is entered statusCode : 404
errorCode : NotFoundException

GetReturnValuetoJSON

{
"postItems": [
{
"key1": "Item1",
"key2": "Item2",
"key3": "Item3"
}
]
}

Inserted data

Param param = new Param();
Dictionary<string, string> dic = new Dictionary<string, string>();

dic.Add("key1", "Item1");
dic.Add("key2", "Item2");
dic.Add("key3", "Item3");

param.Add(columnName, dic);

string rowIndate = Backnd.PlayerTable.Insert(tableName, param).GetInDate();


string Title = "Mail title";
string Content = "Mail content";
string TableName = tableName;
string RowInDate = rowIndate;
string Column = columnName;


Backnd.PlayerMail.SendMail(playerInDate, Title, Content, TableName, RowInDate, Column);

Sample code

void ReceivePostOneInternal(MailType mailType, BackndReturnObject bro) {
if(bro.IsSuccess() == false) {
Debug.LogError($"Failed to claim PlayerMail. : " + bro);
return;
}

StringBuilder stringBuilder = new StringBuilder();

try {
foreach(var postItemKey in bro.GetReturnValuetoJSON()["postItems"].Keys) {
stringBuilder.AppendLine($"{postItemKey} : {postJson[postItemKey].ToString()}");
}
}
catch(Exception e) {
Debug.LogError("An error occurred while parsing the mail items. : " + e);
}

Debug.Log(stringBuilder.ToString());
}