Skip to main content
Version: SDK-5.9.6

ReceivePostItem(Admin, Rank, Coupon)

public BackendReturnObject ReceivePostItem(PostType postType, string postIndate);

Caution
The inDate needed for claiming mail can be loaded with the mail loading method(UPost.GetPostList).
The mail may not be claimed even with a correct inDate if the mail is not loaded.
Only mail added to the mail list through the mail list loading can be claimed.

Parameters

ValueTypeDescription
postTypePostTypeType of the single mail to claim
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 sent after using a coupon with the page created in Web Coupon Settings in BACKND Console
UserUser mail sent using each user's data

Description

Claims one piece of mail using its indate.
You may use the same logic for claiming admin, ranking, and coupon mail, as they all have the same return values 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 removed from the list after being claimed. You can check which items are claimed using returnValue.
  • Users who have claimed the mail are displayed in the mail details in the console's Mail Management along with the date received.(not the case for coupon and user mail)
  • 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.Admin;

//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.Admin;

//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.Admin;

//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

Mail with 0 types of item

{
"postItems": []
}

Mail with 1 type of item

Ranking mails can only have 1 item registered, so only the following format is returned.

{
"postItems": [
{
"item": {
"chartFileName": "chartExample.xlsx",
"itemID": "i101",
"itemName": "Item111",
"hpPower": "1",
"aabab": "1"
},
"itemCount": 1,
"chartName": "Chart"
}
]
}

Mail with 2 or more types of item

{
"postItems": [
{
"item": {
"chartFileName": "chartExample.xlsx",
"itemID": "i101",
"itemName": "Item111",
"hpPower": "1",
"aabab": "1"
},
"itemCount": 1,
"chartName": "Chart"
},
{
"item": {
"chartFileName": "Weapon.xlsx",
"itemID": "sword1",
"itemName": "Longsword",
"atk": "17",
"money": "350"
},
"itemCount": 2
"chartName": "Chart"
}
]
}

Sample code

public class ReceiveItem {

public string chartFileName;
public string itemID;
public string itemName;
public int hpPower;
public int itemCount;

public override string ToString() {
return $"chartFileName:{chartFileName}\n" +
$"itemID:{itemID}\n" +
$"itemName:{itemName}\n" +
$"hpPower:{hpPower}\n" +
$"itemCount:{itemCount}\n";
}
}
public void ReceivePostItemTest() {
BackendReturnObject bro = Backend.UPost.GetPostList(PostType.Coupon, 100);

if(bro.IsSuccess()) {

string postIndate = bro.GetReturnValuetoJSON()["postList"][0]["inDate"].ToString();

var receiveBro = Backend.UPost.ReceivePostItem(PostType.Coupon, postIndate);

if(receiveBro.IsSuccess() == false) {
Debug.LogError("An error occurred while claiming mail. : " + receiveBro);
return;
}

LitJson.JsonData receivePostItemJson = receiveBro.GetReturnValuetoJSON()["postItems"];

for(int i = 0; i < receivePostItemJson.Count; i++) {
ReceiveItem item = new ReceiveItem();
if(receivePostItemJson[i]["item"].ContainsKey("itemName")) {
item.itemName = receivePostItemJson[i]["item"]["itemName"].ToString();
}

// chartFileName does not exist for ranking rewards.
if(receivePostItemJson[i]["item"].ContainsKey("chartFileName")) {
item.chartFileName = receivePostItemJson[i]["item"]["chartFileName"].ToString();
}

if(receivePostItemJson[i]["item"].ContainsKey("itemID")) {
item.itemID = receivePostItemJson[i]["item"]["itemID"].ToString();
}

if(receivePostItemJson[i]["item"].ContainsKey("hpPower")) {
item.hpPower = int.Parse(receivePostItemJson[i]["item"]["hpPower"].ToString());
}

item.itemCount = int.Parse(receivePostItemJson[i]["itemCount"].ToString());

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