List Broadcasts In-Game

In this How-to, we will start a session with the users timezone, retrieve the latest broadcast messages and display the data in your engine.

Prerequisites

Start Session with Timezone Support (Optional)

To ensure broadcast messages are filtered and scheduled according to the players timezone, you can optionally include timezone information when starting a player session.

In this How-To, we are using Guest Login, but all platforms are supported.

using LootLocker.Requests;
using System;

public void StartSessionWithTimezone()
{
    // Create session optionals to include timezone
    LootLockerSessionOptionals optionals = new LootLockerSessionOptionals();
    
    // For Windows, convert the system timezone to IANA format, read more in the section below
    optionals.timezone = LootLockerTimezoneConverter.ConvertWindowsToIanaTzString(TimeZoneInfo.Local.StandardName);
    
    // Start a guest session with timezone
    LootLockerSDKManager.StartGuestSession((response) =>
    {
        if (response.success)
        {
            Debug.Log("Session started successfully with timezone: " + options.timezone);
            // Proceed to retrieve broadcasts
        }
        else
        {
            Debug.LogError("Failed to start session: " + response.errorData.message);
        }
    }, optionals);
}

About Timezones

LootLocker uses the Iana standard for dealing with timezones. A timezone is written to a players metadata with the key ll.timezone.

All platforms except Windows uses Iana. If your game is running on Windows, you must convert the Windows timezone to an Iana timezone before sending it to LootLocker.

Use the utility-class LootLockerTimezoneConverter to convert back and forth between Iana timezones

Retrieve Broadcast Messages

Once you have an active session, you can retrieve broadcast messages that are currently live for your game and display the information in regards to the users preferred language,

Conclusion

In this How-to, we successfully completed the task of retrieving broadcast messages from LootLocker and have displayed their information.

With this implementation, your game can now retrieve rich, localized broadcast messages that are properly scheduled according to player timezones. The multiple localization support allows you to access content in different languages and include custom localized fields like button text, subtitles, and other game-specific content.

Last updated