# SDK 옵트아웃

옵트아웃은 사용자의 데이터 수집을 중단하는 기능입니다. 개인정보 보호 규정 준수나 사용자의 데이터 수집 거부 요청에 대응하기 위해 사용합니다.

{% hint style="info" %}
옵트아웃 상태에서도 A/B 테스트, 기능 플래그, 인앱 메시지 등 SDK 기능은 정상적으로 동작합니다.
{% endhint %}

### 옵트아웃 설정 방법

옵트아웃은 두 가지 방법으로 설정할 수 있습니다:

* **초기화 시 설정**: SDK 초기화 Config에서 `optOutTracking`을 설정합니다.
* **런타임 설정**: `setOptOutTracking()` 메서드를 통해 앱 실행 중에 옵트아웃 상태를 변경합니다.

### 상태 관리

{% hint style="warning" %}
SDK는 옵트아웃 상태를 메모리에서만 관리합니다. 앱이 재시작되면 초기화 Config에 설정된 값으로 리셋됩니다.
{% endhint %}

`setOptOutTracking()`을 통해 변경한 옵트아웃 상태는 앱 재시작 시 유지되지 않습니다. 앱이 다시 시작되면 `HackleConfig`에 설정된 `optOutTracking` 값이 적용됩니다.

#### 영속성 관리

사용자의 옵트아웃 설정을 앱 재시작 후에도 유지하려면, **앱에서 직접 영속적으로 관리**해야 합니다.

**권장 구현 흐름**

1. 사용자가 옵트아웃 설정을 변경하면, 앱의 영속 저장소에 상태를 저장합니다.
2. 앱 시작 시, 저장소에서 옵트아웃 상태를 읽어 SDK 초기화 Config에 설정합니다.
3. 앱 실행 중 상태가 변경되면, 저장소와 SDK 양쪽 모두 업데이트합니다.

**플랫폼별 영속 저장소 예시**

| 플랫폼                | 영속 저장소                                      |
| ------------------ | ------------------------------------------- |
| iOS                | UserDefaults                                |
| Android            | SharedPreferences                           |
| JavaScript / React | localStorage                                |
| React Native       | AsyncStorage 또는 MMKV                        |
| Flutter            | SharedPreferences (shared\_preferences 패키지) |

{% hint style="info" %}
옵트아웃 API의 구체적인 사용법과 영속성 관리 코드 예시는 각 SDK의 옵트아웃 문서를 참고하세요.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hackle.io/development-guide/sdk/optout.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
