Skip to main content
Version: 6.0.0

GetAnnouncementsList

public BackndAnnouncementReturnObject GetAnnouncementsList();
public BackndAnnouncementReturnObject GetAnnouncementsList(int limit);
public BackndAnnouncementReturnObject GetAnnouncementsList(int limit, string firstKey);

Parameters

valueTypedescriptiondefault
limitintNumber of announcements to load10
firstKeystringStarting point of the announcement to be loaded
Can be obtained via BackndReturnObject.LastEvaluatedKeyString().
-

BackndAnnouncementReturnObject

GetReturnValueByAnnouncementList

If an error occurred, null is returned.

using BACKND.Functions;

BackndAnnouncementReturnObject bro = Backnd.Announcement.GetAnnouncementsList(2);

if(bro.IsSuccess()) {
List<BackndAnnouncementItem> announcementList = bro.GetReturnValueByAnnouncementList();
}

BackndAnnouncementItem

public class BackndAnnouncementItem
{
public string title;
public string contents;
public DateTime postingDate;
public string imageKey;
public string inDate;
public string uuid;
public string linkUrl;
public bool isPublic;
public string linkButtonName;
public string author;

public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine($"title : {title}");
stringBuilder.AppendLine($"contents : {contents}");
stringBuilder.AppendLine($"postingDate : {postingDate}");
stringBuilder.AppendLine($"imageKey : {imageKey}");
stringBuilder.AppendLine($"inDate : {inDate}");
stringBuilder.AppendLine($"uuid : {uuid}");
stringBuilder.AppendLine($"linkUrl : {linkUrl}");
stringBuilder.AppendLine($"isPublic : {isPublic}");
stringBuilder.AppendLine($"linkButtonName : {linkButtonName}");
stringBuilder.AppendLine($"author : {author}");

return stringBuilder.ToString();
}
}

Description

This is a function for receiving the announcements registered in BACKND Console.

When the user has a country code, and an announcement of that country is registered in the console → The announcement's title and content for that country will be returned.
If the user's country code is not present, or if an announcement is not registered for the country in the console → Returns the default title and content.

To obtain registered images, add imageKey path that is returned to http://upload-console.thebackend.io.

If the announcement's publicity is set to private, it is excluded from the announcement list that is returned upon calling the method.
You cannot use isPublic's key value to display the announcement on the client.

Example

Synchronous

BackndAnnouncementReturnObject bro = Backnd.Announcement.GetAnnouncementsList(2);

if(bro.IsSuccess()) {
string firstKey = bro.LastEvaluatedKeyString();
if(!string.IsNullOrEmpty(firstKey)) {
// 2. Loads 3 announcements after loading 2 announcements
Backnd.Announcement.GetAnnouncementsList(3, firstKey);
}
}

Asynchronous

Backnd.Announcement.GetAnnouncementsList(2,callback=> {
if(callback.IsSuccess()) {
string firstKey = callback.LastEvaluatedKeyString();
if(!string.IsNullOrEmpty(firstKey)) {
// 2. Loads 3 announcements after loading 2 announcements
Backnd.Announcement.GetAnnouncementsList(3, firstKey, callback2 => {
// Code afterward
});
}
}
});

Return cases

Success cases

When loaded successfully
statusCode : 200

returnValue : refer to GetReturnValuetoJSON

When the number of announcements is 0
statusCode : 200

returnValue : { "rows":[] }


GetReturnValuetoJSON

In the case of success, the information about the registered announcements is displayed.
{
rows:
[
{
content: // Content of announcement
{ S: "The game will be updated on Jan. 31. 2019. Details of the update are as follows: " },
postingDate: // Announcement publication date
{ S : "2018-12-19T09:30:00.000Z" },
imageKey: // Attached image URL
{ S : "/upload/2147483648/notice/2018-12-27T02:55:36.845Z511886972.jpg" },
inDate: // Announcement indate
{ S : "2018-12-19T09:26:53.382Z" },
uuid: // Announcement uuid
{ S : "38b07660-0370-11e9-8d1d-7571a0570adf" },
linkUrl: // External link button URL
{ S : "http://thebackend.io" },
isPublic: // Public/private status
{ S : "y" },
linkButtonName: // The name of the external link
{ S : "buttonN" },
author: // Author
{ S : "jake" },
title: // Announcement title
{ S: "Game update announcement" }
},
{
content: [Object],
postingDate: [Object],
imageKey: [Object],
inDate: [Object],
uuid: [Object],
linkUrl: [Object],
isPublic: [Object],
linkButtonName: [Object],
author: [Object],
title: [Object]
}
],
// Returned when there is data after the loaded data
// Not returned if no data exists after the loaded data
LastEvaluatedKey:{
gamer_id: { S: "notice" },
inDate:{ S: "2019-08-19T06:45:07.816Z" },
partition:{ S: "notice" }
}
}

Sample code

public void GetGetAnnouncementsList()
{
List<Announcement> noticeList = new List<Announcement>();

BackndAnnouncementReturnObject bro = Backnd.Announcement.GetAnnouncementsList(10);
if(bro.IsSuccess())
{
Debug.Log("Return value: " + bro);

BACKND.LitJson.JsonData jsonList = bro.FlattenRows();
for(int i = 0; i < jsonList.Count; i++)
{
Announcement notice = new Announcement();

notice.title = jsonList[i]["title"].ToString();
notice.contents = jsonList[i]["content"].ToString();
notice.postingDate = DateTime.Parse(jsonList[i]["postingDate"].ToString());
notice.inDate = jsonList[i]["inDate"].ToString();
notice.uuid = jsonList[i]["uuid"].ToString();
notice.isPublic = jsonList[i]["isPublic"].ToString() == "y" ? true : false;
notice.author = jsonList[i]["author"].ToString();

if(jsonList[i].ContainsKey("imageKey"))
{
notice.imageKey = "http://upload-console.thebackend.io" + jsonList[i]["imageKey"].ToString();
}
if(jsonList[i].ContainsKey("linkUrl"))
{
notice.linkUrl = jsonList[i]["linkUrl"].ToString();
}
if(jsonList[i].ContainsKey("linkButtonName"))
{
notice.linkButtonName = jsonList[i]["linkButtonName"].ToString();
}

noticeList.Add(notice);
Debug.Log(notice.ToString());
}
}
}

public class Announcement
{
public string title;
public string contents;
public DateTime postingDate;
public string imageKey;
public string inDate;
public string uuid;
public string linkUrl;
public bool isPublic;
public string linkButtonName;
public string author;

public override string ToString()
{
return $"title : {title}\n" +
$"contents : {contents}\n" +
$"postingDate : {postingDate}\n" +
$"imageKey : {imageKey}\n" +
$"inDate : {inDate}\n" +
$"uuid : {uuid}\n" +
$"linkUrl : {linkUrl}\n" +
$"isPublic : {isPublic}\n" +
$"linkButtonName : {linkButtonName}\n" +
$"author : {author}\n";
}
}

How to look up an image attached to the announcement

If you added an image upon registering an announcement, you can check its address by using the imageKey value of GetReturnValuetoJSON() value.

To look up the image, add its image key to the image key returned to http://upload-console.thebackend.io and make a request to the address shown below.

http://upload-console.thebackend.io/upload/2147483648/event/2018-12-27T02:46:57.391Z312652213.jpg
Caution for iOS

iOS blocks http access as a default setting according to its security policy.
If you wish to load an image attached to an announcement/event from an iOS device, allow all http or add certain domains as exceptions as shown below.

Open Info.lplist after building a project > In 'Key,' find or create the value of App Transport Security Settings Key.

Case 1. When allowing all Http access:

Go to App Transport Security Settings and change Allow Arbitrary Loads to YES.

Case 2. When allowing access only from certain domains

  • Go to App Transport Security Settings and change Allow Arbitrary Loads to NO.
  • In the options of App Transport Security Settings, create Exception Domains and add upload-console.thebackend as its subcategory.