# 사용자 동의 관리

Pushwoosh는 개발자가 SDK가 Pushwoosh 서버와 통신을 시작하는 시점을 제어할 수 있도록 하여 개인정보 보호 규정(예: GDPR, CCPA) 준수를 지원합니다. 이를 통해 사용자가 명시적으로 동의하기 전에는 데이터가 수집되지 않도록 보장할 수 있습니다.

### 개요

기본적으로 Pushwoosh SDK는 초기화 즉시 통신을 시작하고 기기 데이터를 수집합니다. 하지만 사용자가 동의할 때까지 통신이 발생하지 않도록 이 동작을 변경할 수 있습니다.

이 설정을 사용하면 다음과 같습니다:

*   사용자가 동의하면 SDK가 초기화되고 데이터 수집을 시작합니다.
*   사용자가 동의하지 않으면 SDK는 비활성 상태로 유지되며 어떠한 데이터도 수집하지 않습니다.
*   사용자가 나중에 동의를 철회하면 SDK는 모든 활동을 중지하고 서버와의 연결을 끊습니다.

Pushwoosh는 iOS, Android 및 Unity에서 이 흐름을 관리하는 메커니즘을 제공합니다.

### iOS

#### 시작 시 SDK 서버 통신 비활성화

기본적으로 SDK와의 통신은 활성화되어 있습니다. 사용자가 명시적으로 동의를 부여할 때까지 Pushwoosh 서버와의 모든 통신을 비활성화하려면 다음 키를 **`Info.plist`**에 추가하십시오:

```xml
<key>Pushwoosh_ALLOW_SERVER_COMMUNICATION</key>
<false/>

```

#### 통신 상태 확인

현재 통신이 허용되는지 확인하려면 다음 메서드를 사용하십시오:

<Tabs>
<TabItem label="SwiftUI">

```swift
import SwiftUI
import PushwooshFramework

var serverCommunicationAllowed = PWCoreServerCommunicationManager.sharedInstance.isServerCommunicationAllowed
print("isServerCommunicationAllowed: ", serverCommunicationAllowed)
```
</TabItem>
<TabItem label="Swift">

```swift
import PushwooshFramework

var serverCommunicationAllowed = PWCoreServerCommunicationManager.sharedInstance.isServerCommunicationAllowed
print("isServerCommunicationAllowed: ", serverCommunicationAllowed)
```
</TabItem>
<TabItem label="Objective-C">

```objective-c
#import <PushwooshFramework/PushwooshFramework.h>

BOOL serverCommunicationAllowed = [PWCoreServerCommunicationManager sharedInstance].isServerCommunicationAllowed;
NSLog(@"isServerCommunicationAllowed: %d", serverCommunicationAllowed);
```
</TabItem>
</Tabs>

#### 동의 후 SDK 통신 활성화

사용자가 동의를 부여하면 다음과 같이 통신을 활성화하십시오:

<Tabs>
<TabItem label="SwiftUI">

```swift
import SwiftUI
import PushwooshFramework

Pushwoosh.sharedInstance().startServerCommunication()
```
</TabItem>
<TabItem label="Swift">

```swift
import PushwooshFramework

Pushwoosh.sharedInstance().startServerCommunication()
```
</TabItem>
<TabItem label="Objective-C">

```objective-c
#import <PushwooshFramework/PushwooshFramework.h>

[[Pushwoosh sharedInstance] startServerCommunication];
```
</TabItem>
</Tabs>

#### 푸시 알림 등록

통신이 활성화되면 푸시 알림을 명시적으로 등록하십시오:

<Tabs>
<TabItem label="SwiftUI">

```swift
import SwiftUI
import PushwooshFramework

Pushwoosh.sharedInstance().registerForPushNotifications()
```
</TabItem>
<TabItem label="Swift">

```swift
import PushwooshFramework

Pushwoosh.sharedInstance().registerForPushNotifications()
```
</TabItem>
<TabItem label="Objective-C">

```objective-c
#import <PushwooshFramework/PushwooshFramework.h>

[[Pushwoosh sharedInstance] registerForPushNotifications];
```
</TabItem>
</Tabs>

#### 통신 비활성화

Pushwoosh 서버와의 통신을 중지하려면(예: 사용자가 동의를 철회하는 경우):

<Tabs>
<TabItem label="SwiftUI">

```swift
import SwiftUI
import PushwooshFramework

Pushwoosh.sharedInstance().stopServerCommunication()
```
</TabItem>
<TabItem label="Swift">

```swift
import PushwooshFramework

Pushwoosh.sharedInstance().stopServerCommunication()
```
</TabItem>
<TabItem label="Objective-C">

```objective-c
#import <PushwooshFramework/PushwooshFramework.h>

[[Pushwoosh sharedInstance] stopServerCommunication];
```
</TabItem>
</Tabs>

### Android

#### 시작 시 SDK 서버 통신 비활성화

기본적으로 통신은 활성화되어 있습니다. 사용자 동의를 얻을 때까지 Pushwoosh 서버로 데이터가 전송되는 것을 방지하려면 다음을 `AndroidManifest.xml`에 추가하십시오:

```xml
<meta-data
  android:name="com.pushwoosh.allow_server_communication"
  android:value="false" />
```

#### 통신 상태 확인

현재 서버 통신이 허용되는지 확인하려면 다음 메서드를 사용하십시오:

<Tabs>
<TabItem label="Java">

```java
import com.pushwoosh.Pushwoosh;

boolean isCommunicationEnabled = Pushwoosh.getInstance().isServerCommunicationAllowed();
Log.d("Pushwoosh", "Communication enabled = " + isCommunicationEnabled);
```
</TabItem>
<TabItem label="Kotlin">

```kotlin
import com.pushwoosh.Pushwoosh

val isCommunicationEnabled = Pushwoosh.getInstance().isServerCommunicationAllowed()
Log.d("Pushwoosh", "Communication enabled = $isCommunicationEnabled")
```
</TabItem>
</Tabs>

#### 동의 후 SDK 통신 활성화

사용자가 동의를 부여하면 다음과 같이 통신을 활성화하십시오:

<Tabs>
<TabItem label="Java">

```java
import com.pushwoosh.Pushwoosh;

Pushwoosh.getInstance().startServerCommunication();
```
</TabItem>
<TabItem label="Kotlin">

```kotlin
import com.pushwoosh.Pushwoosh

Pushwoosh.getInstance().startServerCommunication()
```
</TabItem>
</Tabs>

#### 푸시 알림 등록

통신이 활성화된 후 푸시 알림을 명시적으로 등록하십시오:

<Tabs>
<TabItem label="Java">

```java
import com.pushwoosh.Pushwoosh;

Pushwoosh.getInstance().registerForPushNotifications();
```
</TabItem>
<TabItem label="Kotlin">

```kotlin
import com.pushwoosh.Pushwoosh

Pushwoosh.getInstance().registerForPushNotifications()
```
</TabItem>
</Tabs>

#### 통신 비활성화

Pushwoosh 서버와의 통신을 중지하려면(예: 사용자가 동의를 철회하는 경우):

<Tabs>
<TabItem label="Java">

```java
import com.pushwoosh.Pushwoosh;

Pushwoosh.getInstance().stopServerCommunication();
```
</TabItem>
<TabItem label="Kotlin">

```kotlin
import com.pushwoosh.Pushwoosh

Pushwoosh.getInstance().stopServerCommunication()
```
</TabItem>
</Tabs>

### Unity

#### 시작 시 SDK 서버 통신 비활성화

기본적으로 SDK와의 통신은 활성화되어 있습니다. 사용자가 명시적으로 동의를 부여할 때까지 Pushwoosh 서버와의 모든 통신을 비활성화하려면 플랫폼별 설정을 적용하십시오:

**Android**

Unity 프로젝트의 `AndroidManifest.xml`에 다음을 추가하십시오:

```xml
 <meta-data android:name="com.pushwoosh.allow_server_communication" android:value="false" />
```

**iOS**

`Info.plist`를 수정하십시오:

```xml
<key>Pushwoosh_ALLOW_SERVER_COMMUNICATION</key>
<false/>
```

**참고:** `RegisterForPushNotifications`를 호출하기 전에 통신을 활성화해야 합니다.

#### 통신 상태 확인

현재 서버 통신이 허용되는지 확인하려면 다음 메서드를 사용하십시오:

```c#
bool enabled = Pushwoosh.Instance.IsCommunicationEnabled();
```

#### 동의 후 SDK 통신 활성화

동의 후 통신을 활성화하려면:

```c#
Pushwoosh.Instance.SetCommunicationEnabled(true);
```

#### 푸시 알림 등록

통신이 활성화되면 기기를 푸시 알림에 등록할 수 있습니다:

```c#
Pushwoosh.Instance.RegisterForPushNotifications();
```

#### 통신 비활성화

Pushwoosh 서버와의 통신을 중지하려면(예: 사용자가 동의를 철회하는 경우):

```c#
Pushwoosh.Instance.SetCommunicationEnabled(false);
```

### Web Push

#### 시작 시 자동 구독 비활성화

기본적으로 Pushwoosh SDK는 초기화되자마자 네이티브 구독 프롬프트를 표시합니다. 초기화 시 SDK가 자동으로 구독 프롬프트를 표시하는 것을 방지하려면 `init` 호출에서 `communicationEnabled` 매개변수를 `false`로 설정하십시오.

```html
<script type="text/javascript" src="//cdn.pushwoosh.com/webpush/v3/pushwoosh-web-notifications.js" async></script>
<script type="text/javascript">
  var Pushwoosh = Pushwoosh || [];
  Pushwoosh.push(['init', {
    // other initialization parameters...
    communicationEnabled: false, // Disable communication to prevent automatic subscription prompts
  }]);
</script>
```

#### 동의 후 구독 활성화

자동 구독을 비활성화한 후에는 언제든지 사용자에게 구독을 요청할 수 있습니다. 사용자가 푸시 알림 수신에 동의하면(예: 사용자 지정 UI의 "구독" 버튼 클릭) `setCommunicationEnabled` 메서드를 호출하여 통신을 활성화할 수 있습니다. `Pushwoosh.setCommunicationEnabled(true)`를 호출하면 Pushwoosh 서비스와의 통신이 활성화됩니다. 활성화되면 SDK는 네이티브 브라우저 권한 프롬프트를 표시합니다.

```javascript
Pushwoosh.setCommunicationEnabled(true)
  .then(() => {
    console.log('User is subscribed to push notifications.');
  })
  .catch((error) => {
    console.error('Error subscribing user:', error);
  });
```

#### 통신 비활성화

Pushwoosh 서비스와의 통신을 중지하려면(예: 사용자가 동의를 철회하는 경우) `setCommunicationEnabled`를 `false`로 호출하십시오.

```javascript
Pushwoosh.setCommunicationEnabled(false);
```