Skip to main content
Version: SDK-5.11.4

ReceivePostItem(User)

public BackendReturnObject ReceivePostItem(PostType postType, string postIndate);

Parameters

ValueTypeDescription
postTypePostTypeType of mail to claim all
postIndatestringinDate of the mail from which items were received

PostType

ValueDescription
AdminAdmin mail sent from BACKND Console
RankRanking mail sent automatically after ranking settlement
CouponCoupon mail received by entering a coupon code on the coupon webpage
UserUser mail sent using each user's data

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 mail.

  • The data types "S", "L", and "M" in the return values of the previous mail function(Backend.Social.Post) was removed.
  • Even if indate exists, you cannot claim the mail if it is a different PostType.
  • The mail is not automatically deleted after being claimed. Call the DeleteUserPost method to delete it.
  • You cannot claim expired mail.
  • 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

PostType type = PostType.User;

//Load mail list
BackendReturnObject bro = Backend.UPost.GetPostList(type, limit);
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 PostType
Backend.UPost.ReceivePostItem(type, recentPostIndate);

Asynchronous

// Mail type
PostType type = PostType.User;

//Load mail list
Backend.UPost.GetPostList(type, limit, callback => {
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
Backend.UPost.ReceivePostItem(type, recentPostIndate, callback2 => {
if(callback2.IsSuccess()) {
Debug.Log("Successfully claimed the mail.");
}
});
});

SendQueue

// Mail type
PostType type = PostType.User;

//Load mail list
SendQueue.Enqueue(Backend.UPost.GetPostList, type, limit, callback => {
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 with the same PostType
SendQueue.Enqueue(Backend.UPost.ReceivePostItem, type, recentPostIndate, callback2 => {
if(callback2.IsSuccess()) {
Debug.Log("Successfully claimed the mail.");
}
});
});

Return cases

Success cases

When the mail is claimed successfully
statusCode : 200
message : Success returnValue : refer to GetReturnValuetoJSON

Error cases

When a non-existent postIndate is entered statusCode : 404
errorCode : NotFoundException
message : post not found, post cannot be found

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 = Backend.GameData.Insert(tableName, param).GetInDate();

PostItem postItem = new PostItem {
Title = "Mail title",
Content = "Mail content",
TableName = tableName,
RowInDate = rowIndate,
Column = columnName
};
Backend.UPost.SendUserPost(userIndate, postItem);

Sample code

void ReceivePostOneInternal(PostType postType, BackendReturnObject bro) {
if(bro.IsSuccess() == false) {
Debug.LogError($"Failed to claim mail. : " + 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());
}