Documentation

Did you find this helpful?

Title News

Title News is a mechanism for communicating with your players for patch notes or big events your game may be hosting. It contains a few basic elements: Date, Status, Title, Body, and Language(s). The body is a string, and can contain raw text or JSON.

Requirements:

This tutorial builds on information presented in previous tutorials. Please refer to the tutorials below if you have questions.

  • You should be familiar with Game Manager.
  • Title News can now be localized, so please read up on how to work with default languages on your title and preferred languages for your players in the Setting Default Languages tutorial. You must have a title default language set to continue with localized title news.

Create Title News

PlayFab supports storing localized strings on behalf of game developers by associating a title and body with a language for a title news entry.  We added the necessary logic to provide your players with the correct strings for the language they prefer. When the client queries for title news they will receive different versions of title news based on the players preferred language. You can add multiple translated versions to a single title news.

There are two ways to create Title News entries, via Game Manager and the admin API method AddNews.

To create Title News entries with Game Manager, you will need to be familair with Game Manager.

Game Manager: Navigate to your title -> Content -> Title News -> New Title News

For the purposes of this tutorial, we will assume your title’s default language is English. This means that you must add strings for your default language before you can save the title news.

Adding more languages is as simple as clicking on “add language”, choosing the language you want to add, and then typing in the localized strings. In the above example, we added Korean strings to our title news entry. 

Click "Save Title News" and your entry will be created. The date will be set to when you clicked the "Save Title News" button; you can also edit the timestamp to your preference if you would like a timestamp different from the current time. Timestamp is the time that players will see along with the title news. After saving, you will be redirected back to the page containing the list of your title news entries.

Alternately, you can create Title News by calling AddNews. Using the admin API allows you to specify a custom timestamp. News added this way is immediately published. You can then add localized content to the title news item you just created by calling AddLocalizedNews with the News ID returned from AddNews. Here's a code example:

void CreateNews() {
    PlayFabAdminAPI.AddNews(new AddNewsRequest {
        Timestamp = new DateTime(2014, 1, 8, 12, 0, 0), // Any date - This one is the founding of PlayFab
        Title = "My Second News",
        Body = "This is my second news post."
    }, 
    result => Debug.Log("News post added!"),
    error => Debug.LogError(error.GenerateErrorReport()));
}

void CreateNews() {
    PlayFabAdminAPI.AddLocalizedNewsRequest(new AddLocalizedNewsRequest{
                   NewsId = "74623b12-6c80-ee4b-7c3b-58e638aa62bd",
                   Language = "de"
                   Title = " Meine zweite Nachricht",
                   Body = " Dies ist meine zweite Nachricht."
    }, 
    result => Debug.Log("Localized news post added!"),
    error => Debug.LogError(error.GenerateErrorReport()));
}

Read Title News

Reading the Title News is very simple. The GetTitleNews methods return all published Title News entries. Archived and Unpublished entries will not be returned. Calling GetTitleNews from the client API will return the news entries in the preferred language of the player if the title news item has added localized content in that language, or in the title default language. Calling GetTitleNews from the server API will return the news entries in the title default language.

void ReadTitleNews() {
    PlayFabClientAPI.GetTitleNews(new GetTitleNewsRequest(), result => {
        Debug.Log("Got latest news!");
        // Process news using result.News
    }, error => Debug.LogError(error.GenerateErrorReport()));
}

void ReadTitleNews() {
    PlayFabServerAPI.GetTitleNews(new GetTitleNewsRequest(), result => {
        Debug.Log("Got latest news!");
        // Process news using result.News
    }, error => Debug.LogError(error.GenerateErrorReport()));
}

Update an existing Title News entry

The content of a Title News entry can only be modified in Game Manager. Find the entry you wish to modify:

Game Manager: Navigate to your title -> Content -> Title News -> Select Existing Entry

Update the Title, Status, or Data for the entry, and click "Save Title News". If you are editing a title news that only had title and body in a single language, you can now add localized versions of this title news by clicking “Add Language”.

If plan to post unpublished entries for future release, this will be the way you transition them through published and archived state. Updating title news also lets you fix typos.

Delete Title News

Once an entry is no longer needed, you can delete it in Game Manager. Find the entry you wish to delete:

Game Manager: Navigate to your title -> Content -> Title News -> Checkbox for Existing Entry

Select the Title News entries you wish to delete, and click "X Delete Title News".



Did you find this helpful?