Skip to main content
Version: SDK-5.9.6

GetReceivedMessageList

public BackendReturnObject GetReceivedMessageList();

Description

Looks up the list of received messages.
The list shares a common value with the list of sent messages(GetSentMessageList).(distinguished by message recipient/sender information)

You can keep as many messages as the maximum number set in BACKND Console > Social Management > Settings > Messages, and if you have the maximum number of messages, you will not be able to receive any more.

Example

Synchronous

Backend.Message.GetReceivedMessageList();

Asynchronous

Backend.Message.GetReceivedMessageList((callback) => 
{
// Post-process
});

SendQueue

SendQueue.Enqueue(Backend.Message.GetReceivedMessageList, (callback) => 
{
// Post-process
});

Return cases

Success cases

When the lookup is successful
statusCode : 200
message : Success returnValue : refer to GetReturnValuetoJSON

GetReturnValuetoJSON

It shares a common value with the method that looks up the list of sent messages(GetSentMessageList) and must be distinguished through the recipient and the sender.

{ 
rows:
[
{
receiver: // Message recipient's inDate
{ S : "2018-12-18T01:58:18.722Z" },
sender: // Message sender's inDate
{ S : "2018-12-27T00:21:31.322Z" },
content: // Message content
{ S : "hello this is user7. How are you doing?" },
inDate: // Message's inDate
{ S : "2018-12-27T00:26:22.083Z" },
senderNickname: // Message sender's nickname
{ S : "user7" },
isRead: // Determines whether the recipient has read the message
{ BOOL : false },
receiverNickname: // Message recipient's nickname
{ S : "ryan" },
isReceiverDelete: // Whether the message recipient has deleted the message
{ BOOL : false },
isSenderDelete: // Whether the message sender has deleted the message
{ BOOL : false }
},
{
receiver: [Object],
sender: [Object],
content: [Object],
inDate: [Object],
senderNickname: [Object],
isRead: [Object],
receiverNickname: [Object],
isReceiverDelete: [Object],
isSenderDelete: [Object]
}
]
}

Sample code

public class MessageItem
{
public string receiver;
public string sender;
public string content;
public string inDate;
public string senderNickname;
public bool isRead;
public string receiverNickname;
public bool isReceiverDelete;
public bool isSenderDelete;

public override string ToString()
{
return $"receiver : {receiver}\n" +
$"sender : {sender}\n" +
$"content : {content}\n" +
$"inDate : {inDate}\n" +
$"senderNickname : {senderNickname}\n" +
$"isRead : {isRead}\n" +
$"receiverNickname : {receiverNickname}\n" +
$"isReceiverDelete : {isReceiverDelete}\n" +
$"isSenderDelete : {isSenderDelete}\n";
}
};
public void GetReceivedMessageListTest()
{
var bro = Backend.Message.GetReceivedMessageList();

if(!bro.IsSuccess())
return;

LitJson.JsonData json = bro.FlattenRows();

List<MessageItem> messageList = new List<MessageItem>();

for(int i = 0; i < json.Count; i++)
{
MessageItem messageItem = new MessageItem();

messageItem.receiver = json[i]["receiver"].ToString();
messageItem.sender = json[i]["sender"].ToString();
messageItem.content = json[i]["content"].ToString();
messageItem.inDate = json[i]["inDate"].ToString();
messageItem.senderNickname = json[i]["senderNickname"].ToString();
messageItem.isRead = json[i]["isRead"].ToString() == "true" ? true : false;
messageItem.receiverNickname = json[i]["receiverNickname"].ToString();
messageItem.isReceiverDelete = json[i]["isReceiverDelete"].ToString() == "true" ? true : false;
messageItem.isSenderDelete = json[i]["isSenderDelete"].ToString() == "true" ? true : false;

messageList.Add(messageItem);
Debug.Log(messageItem.ToString());
}
}

GetReceivedMessage

public BackendReturnObject GetReceivedMessage(string messageIndate);

Parameter

ValueTypeDescription
messageIndatestringindate of the received message to read

Description

Reads one received message.

Example

Synchronous

// Get the inDate of the message to read.  
BackendReturnObject bro = Backend.Message.GetReceivedMessageList();
string messageIndate = bro.Rows()[0]["inDate"]["S"].ToString();

// Get the content of the message to read.
BackendReturnObject bro2 = Backend.Message.GetReceivedMessage(messageIndate);
string content = bro2.GetReturnValuetoJSON()["row"]["content"]["S"].ToString();

Asynchronous

// Get the inDate of the message to read.  
Backend.Message.GetReceivedMessageList(callback =>
{
string messageIndate = callback.Rows()[0]["inDate"]["S"].ToString();

// Get the content of the message to read.
Backend.Message.GetReceivedMessage(messageIndate, callback2 =>
{
string content = callback2.GetReturnValuetoJSON()["row"]["content"]["S"].ToString();
});

});

SendQueue

// Get the inDate of the message to read.  
SendQueue.Enqueue(Backend.Message.GetReceivedMessageList, callback =>
{
string messageIndate = callback.Rows()[0]["inDate"]["S"].ToString();

// Get the content of the message to read.
SendQueue.Enqueue(Backend.Message.GetReceivedMessage, messageIndate, callback2 =>
{
string content = callback2.GetReturnValuetoJSON()["row"]["content"]["S"].ToString();
});

});

Return cases

Success cases

When the lookup is successful
statusCode : 200
message : Success returnValue : refer to GetReturnValuetoJSON

GetReturnValuetoJSON

{ 
row:
{
receiver: // Message recipient's inDate
{ S : "2018-12-18T01:58:18.722Z" },
sender: // Message sender's inDate
{ S : "2018-12-27T00:21:31.322Z" },
content: // Message content
{ S : "hello this is user7. How are you doing?" },
inDate: // Message's inDate
{ S : "2018-12-27T00:26:22.083Z" },
senderNickname: // Message sender's nickname
{ S : "user7" },
isRead: // Determines whether the recipient has read the message
{ BOOL : false },
receiverNickname: // Message recipient's nickname
{ S : "ryan" },
isReceiverDelete: // Whether the message recipient has deleted the message
{ BOOL : false },
isSenderDelete: // Whether the message sender has deleted the message
{ BOOL : false }
}
}

Sample code

public class MessageItem
{
public string receiver;
public string sender;
public string content;
public string inDate;
public string senderNickname;
public bool isRead;
public string receiverNickname;
public bool isReceiverDelete;
public bool isSenderDelete;

public override string ToString()
{
return $"receiver : {receiver}\n" +
$"sender : {sender}\n" +
$"content : {content}\n" +
$"inDate : {inDate}\n" +
$"senderNickname : {senderNickname}\n" +
$"isRead : {isRead}\n" +
$"receiverNickname : {receiverNickname}\n" +
$"isReceiverDelete : {isReceiverDelete}\n" +
$"isSenderDelete : {isSenderDelete}\n";
}
};
public void GetReceivedMessageTest()
{
var bro = Backend.Message.GetReceivedMessage("2022-03-14T07:21:01.953Z");

if(!bro.IsSuccess())
return;

LitJson.JsonData json = bro.GetFlattenJSON();

MessageItem messageItem = new MessageItem();

messageItem.receiver = json["row"]["receiver"].ToString();
messageItem.sender = json["row"]["sender"].ToString();
messageItem.content = json["row"]["content"].ToString();
messageItem.inDate = json["row"]["inDate"].ToString();
messageItem.senderNickname = json["row"]["senderNickname"].ToString();
messageItem.isRead = json["row"]["isRead"].ToString() == "true" ? true : false;
messageItem.receiverNickname = json["row"]["receiverNickname"].ToString();
messageItem.isReceiverDelete = json["row"]["isReceiverDelete"].ToString() == "true" ? true : false;
messageItem.isSenderDelete = json["row"]["isSenderDelete"].ToString() == "true" ? true : false;

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