# デジタルサービス法通知

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

###### 最小 SDK バージョン: 3.3.0##minimum-sdk-version-330

[デジタルサービス法](https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=celex%3A32022R2065) が 2024 年 2 月 17 日に完全施行されたことに伴い、新しい通知 API との統合が義務化されています。詳細については、[DSA コンプライアンスの取り組みに関するページ](https://unity.com/legal/digital-services-act) を参照してください。

この記事では、通知 API を統合して以下を行う方法について説明します。

* サインイン済みのプレイヤーに対する新しい通知を確認する。
* バンされたプレイヤーに対する新しい通知を確認する。

## サインイン済みのプレイヤーに対する通知##notifications-for-signed-in-player

プレイヤーがサインインに成功するたびに、Authentication SDK はそのプレイヤーに表示できる通知があるかどうかを検証し、通知がある場合は、`LastNotificationDate` フィールドに最後に作成された通知の日付 (Unix エポックからのミリ秒単位) を設定します。以下のことを行う必要があります。

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