# 디지털 서비스법 알림

> Understand Digital Services Act compliance requirements for publishing games with Unity Authentication in the European Union.

###### 최소 SDK 버전: 3.3.0##minimum-sdk-version-330

2024년 2월 17일부터 전면 시행되는 [디지털 서비스법](https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=celex%3A32022R2065)을 준수하려면 새로운 알림 API와 연동해야 합니다. 자세한 내용은 [DSA 규정 준수 노력 페이지](https://unity.com/legal/digital-services-act)를 참고하십시오.

이 문서에서는 다음과 같은 목적을 위해 API와 연동하는 방법을 설명합니다.

* 로그인한 플레이어에 대한 새 알림 확인
* 차단한 플레이어에 대한 새 알림 확인

## 로그인한 플레이어에 대한 알림##notifications-for-signed-in-player

플레이어가 로그인할 때마다 Authentication SDK는 해당 플레이어에게 제공되는 알림이 있는지 확인하고 Unix 시점부터 마지막 알림이 생성된 날짜(밀리초 단위)로 `LastNotificationDate` 필드를 채웁니다. 다음을 수행해야 합니다.

1. 플레이어가 로그인할 때마다 `LastNotificationDate` 필드가 null이 아닌지, 즉 해당 플레이어에게 제공되는 알림이 있는지 확인합니다. 알림 샘플: “귀하의 계정 또는 콘텐츠가 DSA 조치의 영향을 받았습니다. 세부 정보를 검색하고 \[링크]를 통해 이의를 제기하십시오(사례 ID \[삽입] 및 플레이어 ID \[삽입] 필요).”
   1. 개발자는 플레이어에게 이 문구를 표시할 책임이 있습니다.
2. `LastNotificationDate`의 값이 플레이어가 마지막으로 읽은 알림에 대해 저장한 값보다 큰지 확인합니다.
3. `GetNotificationsAsync` 메서드를 호출하여 플레이어의 알림을 검색합니다.
4. 플레이어에게 알림을 표시합니다. (알림은 `GetNotificationsAsync` 메서드의 반환 값에서 사용할 수 있으며 `Notifications` 필드에도 캐시됩니다.)
5. 플레이어가 알림을 읽으면 해당 알림의 `CreatedAt` 값과 플레이어가 마지막으로 읽은 알림의 저장된 값 중 더 큰 값을 저장해야 합니다.

## 제한된 플레이어에 대한 알림##notifications-for-a-restricted-player

플레이어가 로그인을 시도하다가 제한되어 로그인에 실패하면(예: 금지 또는 비활성화된 경우) `AuthenticationException`이 발생합니다. 여기에는 해당 플레이어가 사용할 수 있는 모든 알림이 포함된 `Notifications` 필드가 포함되며, 사용할 수 있는 알림이 없는 경우 null이 됩니다. 다음을 수행해야 합니다.

1. 로그인 시도가 실패할 때마다 예외가 `AuthenticationException`인지 확인합니다.
2. Notifications 필드가 null이 아닌지 확인합니다.
3. 플레이어에게 알림을 표시합니다.

주요 알림 필드는 다음과 같습니다.

* `CaseId`: 플레이어가 알림에 대한 추가 세부 정보를 요청할 수 있는 사례 식별자입니다.
* `ProjectId`: 플레이어가 알림에 대한 추가 세부 정보를 요청할 수 있는 클라우드 프로젝트 식별자입니다.
* `Message`: 플레이어에게 표시할 알림의 내용입니다. 예: “귀하의 계정 또는 콘텐츠가 DSA 조치의 영향을 받았습니다. 세부 정보를 검색하고 \[링크]를 통해 이의를 제기하십시오(사례 ID \[삽입] 및 플레이어 ID \[삽입] 필요).”
* `CreatedAt`: 알림이 생성된 시점의 타임스탬프입니다. 플레이어에게 새로운 알림이 제공되는지 식별하는 데 사용됩니다.

```cs
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
    ...
}
```
