GS2-News SDK for Game Engine API Reference

Specifications of models and API references for GS2-News SDK for Game Engine

Model

EzNews

News Article

Represents a single news article generated from Hugo site data. Each article belongs to a section and content path, and has a title, timestamp, and front matter metadata. Articles can optionally be linked to a GS2-Schedule event to control their display period. The front matter contains additional metadata in JSON format, including an optional weight field for controlling display order.

TypeConditionRequiredDefaultValue LimitsDescription
sectionstring
~ 1024 charsSection Name
The section (category) to which this article belongs, corresponding to the Hugo content directory structure.
Used to organize articles into logical groups for display.
contentstring
~ 1024 charsContent
The content path identifier for this article within its section.
Together with the section, uniquely identifies the article’s location in the Hugo content structure.
titlestring
~ 1024 charsArticle Headline
The title of the news article, typically defined in the Hugo front matter.
Displayed as the headline when listing articles for the player.
scheduleEventIdstring~ 1024 charsGS2-Schedule Event GRN
timestamplong
Timestamp
Unix time, milliseconds
frontMatterstring
~ 1024 charsFront Matter
Metadata associated with the article in JSON format, originally defined in the Hugo markdown front matter.
May contain arbitrary fields such as weight (for controlling display order), tags, categories, and other custom properties.

EzSetCookieRequestEntry

Set Cookie Request Entry

Represents a cookie key-value pair that must be set in the browser/WebView to access the news article web content. The client must set these cookies before loading the article URLs to ensure authorized access to the content.

TypeConditionRequiredDefaultValue LimitsDescription
keystring
~ 128 charsCookie Key
The name of the cookie that must be set for authenticated access to the news content.
Maximum 128 characters.
valuestring
~ 1024 charsCookie Value
The value of the cookie that must be set for authenticated access to the news content.
Maximum 1024 characters.

Methods

getContentsUrl

Get the URL and cookies needed to display news content

Retrieves the information required to display news articles in a WebView or browser. News content is hosted as web pages, so to display them you need: (1) cookies for authentication, and (2) the URL to open. The response includes a browser URL (requires cookies to be set first) and a ZIP URL (for downloading all content without cookies — useful for offline or custom rendering). Use this before opening a news article — for example, call this API, set the returned cookies in the WebView, then navigate to the browser URL to show the article. Alternatively, download the ZIP to render the content natively in your game UI.

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
gameSessionGameSession
GameSession

Result

TypeDescription
itemsList<EzSetCookieRequestEntry>List of cookies that need to be set in order to access the content
browserUrlstringURL to access the content
zipUrlstringURL to access the announcement contents in ZIP format (Cookie setting is not required for access)

Implementation Example

    var domain = gs2.News.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).News(
    );
    var result = await domain.GetContentsUrlAsync(
    );
    List<EzSetCookieRequestEntry> cookies = new List<EzSetCookieRequestEntry>();
	var items = result.ToList();
	foreach (var item in items)
	{
	  var entry = await item.ModelAsync();
	  cookies.Add(entry);
	}
    var browserUrl = domain.BrowserUrl;
    var zipUrl = domain.ZipUrl;
    var domain = gs2.News.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    ).News(
    );
    var future = domain.GetContentsUrlFuture(
    );
    yield return future;
    if (future.Error != null)
    {
        onError.Invoke(future.Error, null);
        yield break;
    }
    List<EzSetCookieRequestEntry> cookies = new List<EzSetCookieRequestEntry>();
    var result = future.Result;
    var items = result.ToList();
    foreach (var item in items)
    {
        var future2 = item.Model();
	    yield return future2;
	    var entry = future2.Result;
	    cookies.Add(entry);
    }
    var browserUrl = domain.BrowserUrl;
    var zipUrl = domain.ZipUrl;
    const auto Domain = Gs2->News->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    )->News(
    );
    const auto Future = Domain->GetContentsUrl(
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }
    TArray<EzSetCookieRequestEntryPtr> Cookies;
	const auto It = Future->GetTask().Result();
	foreach (auto Item in It)
	{
        const auto Future2 = Item.Model();
        Future2->StartSynchronousTask();
        if (Future2->GetTask().IsError())
        {
            return Future2->GetTask().Error();
        }
        Cookies.Add(Future2->GetTask().Result());
	}
    const auto BrowserUrl = Domain->BrowserUrl;
    const auto ZipUrl = Domain->ZipUrl;

listNewses

Get a list of news articles

Retrieves the list of in-game news articles (announcements) for the player. News articles are HTML-based web content managed through GS2 — for example, maintenance notices, event announcements, update patch notes, and campaign information. The response also includes hash values for cache validation, so you can check if the content has changed since the last fetch. Use this to build an in-game news/announcements screen — for example, showing a list of articles like “Maintenance on March 1st”, “New Event: Spring Festival”, “Version 2.5 Update Notes”.

Request

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
gameSessionGameSession
GameSession

Result

TypeDescription
itemsList<EzNews>List of News Articles
contentHashstringHash value of News Article data
templateHashstringHash value of template data

Implementation Example

    var domain = gs2.News.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var items = await domain.NewsesAsync(
    ).ToListAsync();
    var domain = gs2.News.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var it = domain.Newses(
    );
    List<EzNews> items = new List<EzNews>();
    while (it.HasNext())
    {
        yield return it.Next();
        if (it.Error != null)
        {
            onError.Invoke(it.Error, null);
            break;
        }
        if (it.Current != null)
        {
            items.Add(it.Current);
        }
        else
        {
            break;
        }
    }
    const auto Domain = Gs2->News->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    );
    const auto It = Domain->Newses(
    );
    TArray<Gs2::UE5::News::Model::FEzNewsPtr> Result;
    for (auto Item : *It)
    {
        if (Item.IsError())
        {
            return false;
        }
        Result.Add(Item.Current());
    }