> For the complete documentation index, see [llms.txt](https://platform-business.gitbook.io/klat/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://platform-business.gitbook.io/klat/unity/push-notification.md). Agents can also search and read this documentation through its [MCP server](https://platform-business.gitbook.io/klat/~gitbook/mcp).

# Push Notification

### Enable / Disable Push Notification

사용자가 Push Notification을 받을 지 여부를 설정할 수 있습니다.

```csharp
// 사용자 Push Notification 활성화
TalkPlusApi.EnablePushNotification(() => {
   // SUCCESS
}, (int statusCode, Exception e) => {
   // FAILURE
});

// 사용자 Push Notification 비활성화
TalkPlusApi.DisablePushNotification(() => {
   // SUCCESS
}, (int statusCode, Exception e) => {
   // FAILURE
});
```

특정 채널의 Push Notification을 받을 지 여부를 설정할 수 있습니다.

```csharp
// 채널 Push Notification 활성화
TalkPlusApi.EnableChannelPushNotification(channel, (TPChannel channel) => {
   // SUCCESS
}, (int statusCode, Exception e) => {
   // FAILURE
});

// 채널 Push Notification 비활성화
TalkPlusApi.DisableChannelPushNotification(channel, (TPChannel channel) => {
   // SUCCESS
}, (int statusCode, Exception e) => {
   // FAILURE
});
```

### Push Notification

TalkPlus의 Push Notification은 FCM을 통하여 이루어지게 됩니다. 기본적인 FCM을 연동하신 후, User를 로그인한 후 `RegisterFCMToken` 함수를 호출하여 FCM 토큰을 User 세션에 연동하여야 합니다.

```csharp
TalkPlusApi.RegisterFCMToken(fcmToken, () => {
   // SUCCESS
}, (int statusCode, Exception e) => {
   // FAILURE
});
```

이후 아래와 같이 `OnMessageReceived`에 TalkPlus에서 제공하는 `ProcessFirebaseCloudMessagingData` 함수를 호출하는 코드를 삽입하여 Push Notification을 처리할 수 있습니다.

```csharp
public static void OnMessageReceived(object sender, MessageReceivedEventArgs e)
{
    if (e.Message.Data.ContainsKey("talkplus"))
    {
        TalkPlusApi.ProcessFirebaseCloudMessagingData(e.Message.Data);
    }
}
```
