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.
When a DSA notification is sent to a user, it will contain the following notable fields:
CaseId
: A 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.
This page explains how to integrate with the Notification APIs to check both sign-in players and restricted players. Restricted players are those who have been banned or disabled.
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:
- Check if the
AuthenticationService.Instance.LastNotificationDate
field is not null after every successful sign in. If it is not null, then there are notifications available for that player. - Confirm if the
LastNotificationDate
is greater than the value you stored for the last notification the player read. - Retrieve the player's notifications by calling the
GetNotificationsAsync
method. - Display the notifications to the player. (The notifications are available in the return value of the
GetNotificationsAsync
method and are also cached in theNotifications
field.) - 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:
- Check if the exception is an
AuthenticationException
, after every failed sign in attempt. - Confirm that the
Notifications
field is not null. - Display the notifications to 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;
// Retrieve the last notification read createdAt date from storage
long storedNotificationDate = 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)
{
// Retrieve the last notification read createdAt date from storage
var storedNotificationDate = GetLastNotificationReadDate();
var notificationDate = long.Parse(notification.CreatedAt);
if (notificationDate > storedNotificationDate)
{
SaveNotificationReadDate(notificationDate);
}
}
void SaveNotificationReadDate(long notificationReadDate) {
// Store the notificationReadDate, e.g.: PlayerPrefs
}
long GetLastNotificationReadDate() {
// Retrieve the notificationReadDate that was stored in SaveNotificationReadDate, e.g.: PlayerPrefs
...
}