Digital Services Act Notifications

Minimum SDK version: 3.3.0

To comply with the Digital Services Act, which takes full effect on February 17, 2024, you must integrate with the new Notifications APIs. Refer to our DSA compliance efforts page for more information.

This article explains how to integrate with the Notification APIs to:

  • Check for new notifications for a signed in player.
  • Check for new notifications for a banned player.

Notifications for signed in player

Every time a player successfully signs in, the Authentication SDK validates if there are any notifications available for that player and populates the LastNotificationDate field with the date the last notification was created, in milliseconds, since Unix epoch. You must:

  1. Confirm the LastNotificationDate field is not null after every successful sign in, meaning there are notifications available for that player. A sample of the notification: “Your account or content has been affected by DSA action. Retrieve details and appeal via: [Link] (Case ID [insert] and Player ID [insert] needed)."
    1. The developer is responsible for displaying the text to the player.
  2. Confirm if the LastNotificationDate is greater than the value you stored for the last notification the player read.
  3. Retrieve the player's notifications by calling the GetNotificationsAsync method.
  4. Display the notifications to the player. (The notifications are available in the return value of the GetNotificationsAsync method and are also cached in the Notifications field.)
  5. When the player reads a notification you must store the greater value between that notification's CreatedAt value and the stored value for the player's last read notification.

Notifications for a restricted player

When a player tries to sign in and fails due to them being restricted (for example, they have been banned or disabled), an AuthenticationException is thrown. This contains a Notifications field which contains all notifications available to that player, or is null if none are available. You must:

  1. Confirm if the exception is an AuthenticationException, after every failed sign in attempt.
  2. Confirm if the Notifications field isn't null.
  3. Display the notifications to the player.

Notable notification fields:

  • CaseId: The case identifier to allow the player to request more details on the notification.
  • ProjectId: The Cloud Project identifier to allow the player to request more details on the notification.
  • Message: The content of the notification to display to the player, for example, "Your account or content has been affected by DSA action. Retrieve details & appeal via: [Link] (Case ID [insert] & Player ID [insert] needed)."
  • CreatedAt: Timestamp for when the notification was created. Used to identify new notifications are available for the player.
async Task SignInWithNotifications()
{
    List<Notification> notifications = null;
    try
    {
        // Sign the Player In, Anonymously in this example
        await AuthenticationService.Instance.SignInAnonymouslyAsync();
        // Verify the LastNotificationDate
        var lastNotificationDate = AuthenticationService.Instance.LastNotificationDate;
        long storedNotificationDate = // Retrieve the last notification read createdAt date from storage using GetLastNotificationReadDate();
        // Verify if the LastNotification date is available and greater than the last read notifications
        if (lastNotificationDate != null && long.Parse(lastNotificationDate) > storedNotificationDate)
        {
            // Retrieve the notifications from the backend
            notifications = await AuthenticationService.Instance.GetNotificationsAsync();
        }
    }
    catch (AuthenticationException e)
    {
    	// Read notifications from the banned player exception
        notifications = e.Notifications;
        // Notify the player with the proper error message
        Debug.LogException(e);
    }
    catch (Exception e)
    {
        // Notify the player with the proper error message
        Debug.LogException(e);
    }

    if (notifications != null)
    {
        // Display notifications
    }
}

void OnNotificationRead(Notification notification)
{
    long storedNotificationDate = // Retrieve the last notification read createdAt date from storage GetLastNotificationReadDate();
    var notificationDate = long.Parse(notification.CreatedAt);
    if (notificationDate > storedNotificationDate)
    {
        SaveNotificationReadDate(notificationDate);
    }
}

void SaveNotificationReadDate(notificationReadDate) {
    // Store the notificationReadDate, e.g.: PlayerPrefs
}

long GetLastNotificationReadDate() {
    // Retrieve the notificationReadDate that was stored in SaveNotificationReadDate, e.g.: PlayerPrefs
    ...
}