Sign In Register

How can we help you today?

Start a new topic
Answered

ListMessageRequest Empty List ?

 Hello their !

After 8h I'm still in trouble with the List message request. I've send a test message that log in Unity thanks to the Platformbase code :

public void DebugMsg(String message){
ExecuteOnMainThread(() => {
if (message.Length < 1500)
{
Debug.Log("GS: " + message);
} else
{
Debug.Log("GS: " + message.Substring(0, 1500) + "...");
}
GameSparksController.Instance.CheckMessage();
});
}

And I'm able to see it in the Test harness but I have issue on how to use it in unity as I want.
The following code Log " List message succes " but the list is empty .... Any ideas ? Am i missing something ?

:
new ListMessageRequest().Send((response) =>
{

if (!response.HasErrors)
{
Debug.Log("List message success");
foreach (var data in MessageList)
{
Debug.Log("message");
}

}
else
{
Debug.Log("List message error");
}

});


Thanks in advance !


Best Answer

Hi Lorent

To get the message list from the response use


IList<GSData> messageList = response.MessageList;


The c# listmessagerequest API can be found here


Thanks

Katie



Hi Lorent

Are you using the latest gameSparks SDK ? If not please update, the sdk can be found here
Using the newest SDK should give you a response.
To iterate through the response and put them in an array

 

ArrayList messageList = new ArrayList(); 
 
new ListMessageRequest().Send((response) =>
      {

          foreach (var c in response.MessageList)
          {
              messageList.Add(c.GetString("messageId"));
          }
         
      });

 


Thanks
Katie

 

Thanks for the response, but I still have an empty list. How can I iterate trought this GsData List ?

"Debug.Log(response.JSONString);" shows me my messages so I'm sure to have it, anyway the list is still empty.

Thanks in advance.

 

Answer

Hi Lorent

To get the message list from the response use


IList<GSData> messageList = response.MessageList;


The c# listmessagerequest API can be found here


Thanks

Katie


You are right Deftouch, sorry for the customer service but their answer doesn't work. 
Here is how I did :

  this.messages = new List<GSMessage>();
  new ListMessageRequest().SetDurable(true).Send((response) =>
  {
  Debug.Log(response.JSONString);
  List<GSData> mlist = response.BaseData.GetGSDataList("messageList");
  foreach (GSData data in mlist)
  {
  GSMessage o = new GSMessage(data);
  this.messages.Add(o);
  }
  });
  }


Hope this help ! If so, up my answer because the wrong answer is mark as the best ( lulz )

Good day !

 

hey Lorent, looks like the API has changed. 
I posted a similar question here https://support.gamesparks.net/support/discussions/topics/1000078809 where they gave me the correct solution.


Anyway thanks for the response.

Hi Lorent,

Did this work for you? It never enters the foreach loop in my case.


This statement gives a compile error : 

IList<GSData> messageList = response.MessageList; 


Regards

 Yep, that's the same way I did...Funny I found it before customer service haha :D

Login to post a comment