EventList
public BackendReturnObject EventList();
public BackendReturnObject EventList(int limit);
public BackendReturnObject EventList(int limit, string offset);
Parameters
Value | Type | Description |
---|---|---|
limit | int | (Optional) Number of events to be loaded |
offset | string | (Optional) Starting point of the events to be loaded It can be obtained via BackendReturnObject.LastEvaluatedKeyString(). |
Description
This is a function for receiving the events registered in BACKND Console.
- When the user has a country code and an event of that country is registered in the console → The event's title and content for that country will be returned.
- If the user's country code is not present, or if an event is not registered for the country in the console → Returns the default title and content.
Example
Synchronous
//Calls 10 events lists
BackendReturnObject bro = Backend.Event.EventList(10);
if(bro.IsSuccess()) {
//Event 10 after calling 10 events
string offset = bro.LastEvaluatedKeyString();
if(!string.IsNullOrEmpty(offset)) {
// 2. Loads 3 events after loading 2 events
Backend.Event.EventList(3, offset);
}
}
Asynchronous
Backend.Event.EventList(2, (callback) => {
// Post-process
if(callback.IsSuccess()) {
string offset = callback.LastEvaluatedKeyString();
if(!string.IsNullOrEmpty(offset)) {
// 2. Loads 3 events after loading 2 events
Backend.Event.EventList(3, offset, (callback2) => {
// Post-process
});
}
}
});
SendQueue
SendQueue.Enqueue(Backend.Event.EventList, 2, (callback) => {
// Post-process
if(callback.IsSuccess()) {
string offset = callback.LastEvaluatedKeyString();
if(!string.IsNullOrEmpty(offset)) {
// 2. Loads 3 events after loading 2 events
SendQueue.Enqueue(Backend.Event.EventList, 3, offset, (callback2) => {
// Post-process
});
}
}
});
Return cases
Success cases
When loaded successfully
statusCode : 200
returnValue : refer to GetReturnValuetoJSON
When the number of events is 0
statusCode : 200
returnValue : { "rows":[] }
GetReturnValuetoJSON
In the case of success, the information about the registered events is displayed.
{
rows:
[
{
uuid: // Event uuid
{ S : "b33bc260-0981-11e9-bfd0-3bf848e9c52c" },
content: // Content of event
{ S: "Enter a coupon number to receive items!" },
contentImageKey: // Attached content image URL
{ S : "/upload/2147483648/event/2018-12-27T02:46:57.391Z312652213.jpg" },
popUpImageKey: // Attached pop-up image URL
{ S : "/upload/2147483648/event/2018-12-27T02:46:58.945Z936251230.jpg" },
postingDate: // Event publication date
{ S : "2018-12-27T02:00:00.000Z" },
endDate: // Event end date
{ S : "2018-12-28T03:00:00.000Z" },
inDate: // Event indate
{ S : "2018-12-27T02:47:07.399Z" },
startDate: // Event start date
{ S : "2018-12-27T03:00:00.000Z" },
linkUrl: // External link button URL
{ S : "http://thebackend.io" },
isPublic: // Public/private status(y: public)
{ S : "y" },
linkButtonName: // The name of the external link
{ S : "buttonX" },
author: // Author information(admin nickname)
{ S : "jake" },
title: // Event title
{ S: "An event to celebrate 100,000 downloads!" }
},
{
uuid: [Object],
content: [Object],
contentImageKey: [Object],
popUpImageKey: [Object],
postingDate: [Object],
endDate: [Object],
inDate: [Object],
startDate: [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: "event" },
inDate:{ S: "2019-08-19T06:45:07.816Z" },
partition:{ S: "event" }
}
}
Sample code
public class EventItem
{
public string uuid;
public string content;
public string contentImageKey;
public string popUpImageKey;
public DateTime postingDate;
public DateTime startDate;
public DateTime endDate;
public string inDate;
public string linkUrl;
public string author;
public bool isPublic;
public string linkButtonName;
public string title;
public override string ToString()
{
return $"uuid : {uuid}\n" +
$"content : {content}\n" +
$"contentImageKey : {contentImageKey}\n" +
$"popUpImageKey : {popUpImageKey}\n" +
$"postingDate : {postingDate}\n" +
$"startDate : {startDate}\n" +
$"endDate : {endDate}\n" +
$"inDate : {inDate}\n" +
$"linkUrl : {linkUrl}\n" +
$"author : {author}\n" +
$"isPublic : {isPublic}\n" +
$"linkButtonName : {linkButtonName}\n" +
$"title : {title}\n";
}
}
public void EventListTest()
{
List<EventItem> eventList = new List<EventItem>();
BackendReturnObject bro = Backend.Event.EventList(10);
if(bro.IsSuccess())
{
Debug.Log("Return value: " + bro);
LitJson.JsonData jsonList = bro.FlattenRows();
for(int i = 0; i < jsonList.Count; i++)
{
EventItem eventItem = new EventItem();
eventItem.title = jsonList[i]["title"].ToString();
eventItem.content = jsonList[i]["content"].ToString();
eventItem.postingDate = DateTime.Parse(jsonList[i]["postingDate"].ToString());
eventItem.startDate = DateTime.Parse(jsonList[i]["startDate"].ToString());
eventItem.endDate = DateTime.Parse(jsonList[i]["endDate"].ToString());
eventItem.inDate = jsonList[i]["inDate"].ToString();
eventItem.uuid = jsonList[i]["uuid"].ToString();
eventItem.isPublic = jsonList[i]["isPublic"].ToString() == "y" ? true : false;
eventItem.author = jsonList[i]["author"].ToString();
if(jsonList[i].ContainsKey("contentImageKey"))
{
eventItem.contentImageKey = "http://upload-console.thebackend.io" + jsonList[i]["contentImageKey"].ToString();
}
if(jsonList[i].ContainsKey("popUpImageKey"))
{
eventItem.popUpImageKey = "http://upload-console.thebackend.io" + jsonList[i]["popUpImageKey"].ToString();
}
if(jsonList[i].ContainsKey("linkUrl"))
{
eventItem.linkUrl = jsonList[i]["linkUrl"].ToString();
}
if(jsonList[i].ContainsKey("linkButtonName"))
{
eventItem.linkButtonName = jsonList[i]["linkButtonName"].ToString();
}
eventList.Add(eventItem);
Debug.Log(eventItem.ToString());
}
}
}
How to look up an image attached to the event
If you registered a content image and pop-up image when registering the event, you can check the address where the images are stored using the contentImageKey and popUpImageKey values, respectively, in the above 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
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.