Skip to main content
Version: SDK-5.11.2

Differences With the Previous Mail Function

Mail loading logic updated

The loading function of the previous mail function(Social.Post) was a logic that read 100 pieces of most recently sent mail in the mailbox.
This logic could load most of the mail, but any extra after the valid 100th one could not be loaded.

In order to fix this problem, the mail function has been improved.
The new mail function(UPost) starts loading the number of mail equal to the set limit, starting from the oldest piece of mail you can receive.
Subsequent calls will slowly start retrieving recent mail, starting from the piece that it last loaded.
Although the first call may not load any mail, every call will be accumulated, and the mail list will be updated.

The limit is set to 10 by default. A lower limit will load the mail faster, and a higher limit will load a larger amount of mail but with more delay.

Setting the limit to 100 will imitate the previous mail function's behavior.
Backend.UPost.GetPostList(PostType.Admin, 100);

Additional mail functions for the console

The following functions were added to the mail function along with the BACKND Console revamp on December 28, 2021:

  1. Can now choose 0-10 item types(fixed to 1 in the previous version)
  2. Can specify the author(sender) of the mail
  3. Can upload a sender chart

The first two functions above are not available in the previous mail function of the SDK; you can use them only with the new mail function.
The previous mail function can load and claim only those with a single item.

Differences with the SDK mail function

Previous mail function

The following statements explain how the previous mail function works.

  1. Mail sent from the console(admin + mail) and mail sent by users can be loaded at once with the mail loading method.
  2. The JSON returned upon loading and claiming mail contains "M", "N", "L", etc., indicating the data type.
  3. Admin mail is loaded only if it has a single item.(Others are excluded from the list.)
  4. You cannot specify the author(sender).
  5. The 100 most recent pieces of mail are loaded.

Current mail function

The following statements explain how the current mail function works.

  1. Select which type of mail to load among Admin, Ranking, and User.
  2. The "M", "S", and "L" data types no longer exist in the JSON returned upon loading and claiming mail.
  3. All pieces of admin mail are retrieved, regardless of the number of item types.
  4. You can specify the author.
  5. The list is updated by searching for the amount set as the limit from the old mail list.

Code of the changed mail function

The return values are somewhat different between the two versions.

Code for the new version(UPost)

public void GetPostList()
{
var bro = Backend.UPost.GetPostList(PostType.Admin, 100);
LitJson.JsonData json = bro.GetReturnValuetoJSON()["postList"];

for(int i = 0; i < json.Count; i++)
{
string postTitle = json[i]["title"].ToString(); // Mail title
string postContent = json[i]["content"].ToString(); // Mail content
string postAuthor = json[i]["author"].ToString(); // Mail author

int postItemCount = (int)json[i]["itemCount"]; // Code simplified by removing the problematic data type

string postIndate = json[i]["inDate"].ToString();

ReceivePostItem(PostType.Admin, postIndate); // Claim mail
}
}
public void ReceivePostItem(PostType postType, postIndate)
{
var bro = Backend.UPost.ReceivePostItem(postType, postIndate);
LitJson.JsonData postList = bro.GetReturnValuetoJSON()["postItems"];
for(int i=0; i < postList.Count; i++)
{
if(postList[i].Count <= 0)
{
Debug.Log("Mail with no item");
continue;
}
string itemName = postList[i]["item"]["itemName"];
int itemCount = (int)postList[i]["itemCount"];
}
}

Code for the previous version(Post)

var bro = Backend.Social.Post.GetPostListV2();
LitJson.JsonData json = bro.GetReturnValuetoJSON()["fromAdmin"];

for(int i = 0; i < json.Count; i++)
{
string postTitle = json[i]["title"]["S"].ToString();
string postContent = json[i]["content"]["S"].ToString();
int postItemCount = string.Empty;
if(json[i]["itemCount"].ContainsKey("S")) // All pieces of ranking mail have data types set to "S" and require to be handled as an exception.
{
postItemCount = (int)json[i]["itemCount"]["S"];
}
if(json[i]["itemCount"].ContainsKey("N")) // Ranking mail and admin mail use different data types for itemCount.
{
postItemCount = (int)json[i]["itemCount"]["N"];
}
string postIndate = json[i]["inDate"]["S"].ToString();

}

public void ReceivePostItem()
{
var bro = Backend.Social.Post.ReceiveAdminPostItemV2(postIndate);

LitJson.JsonData json = bro.GetReturnValuetoJSON();

string itemName = json[i]["item"]["M"]["itemName"]["S"].ToString();
int itemCount = (int)json["itemCount"]["S"];
}