> ## Documentation Index
> Fetch the complete documentation index at: https://docs.adrop.io/llms.txt
> Use this file to discover all available pages before exploring further.

# UMP 연동

> GDPR/CCPA 규정 준수를 위한 Google UMP 연동

## 개요

UMP(User Messaging Platform) SDK는 GDPR(일반 데이터 보호 규정) 및 CCPA(캘리포니아 소비자 개인정보 보호법) 준수를 위해 맞춤형 광고에 대한 사용자 동의를 관리합니다.

<Note>
  UMP 연동에는 `adrop-ads-backfill` 모듈이 필요합니다. [시작하기](/ko/sdk/ios/overview)의 설치 가이드를 먼저 완료해주세요.
</Note>

***

## 기본 사용법

Adrop 초기화 후 Consent Manager를 사용하여 사용자 동의를 요청합니다.

<CodeGroup>
  ```swift Swift theme={null}
  import AdropAds

  class ViewController: UIViewController {

      override func viewDidLoad() {
          super.viewDidLoad()

          // Adrop.initialize() 이후에 호출
          Adrop.consentManager?.requestConsentInfoUpdate(from: self) { result in
              if let error = result.error {
                  print("동의 오류: \(error)")
              }
          }
      }
  }
  ```

  ```objc Objective-C theme={null}
  @import AdropAds;

  @implementation ViewController

  - (void)viewDidLoad {
      [super viewDidLoad];

      // Adrop.initialize() 이후에 호출
      if (Adrop.consentManager != nil) {
          [Adrop.consentManager requestConsentInfoUpdateFrom:self completion:^(AdropConsentResult *result) {
              if (result.error != nil) {
                  NSLog(@"동의 오류: %@", result.error);
              }
          }];
      }
  }

  @end
  ```
</CodeGroup>

***

## 동의 결과

`requestConsentInfoUpdate` 콜백은 다음 프로퍼티를 가진 `AdropConsentResult` 객체를 반환합니다:

| 프로퍼티                     | 타입                   | 설명              |
| ------------------------ | -------------------- | --------------- |
| `status`                 | `AdropConsentStatus` | 현재 동의 상태        |
| `canRequestAds`          | `Bool`               | 광고 요청 가능 여부     |
| `canShowPersonalizedAds` | `Bool`               | 맞춤형 광고 표시 가능 여부 |
| `error`                  | `Error?`             | 요청 실패 시 에러      |

<CodeGroup>
  ```swift Swift theme={null}
  Adrop.consentManager?.requestConsentInfoUpdate(from: self) { result in
      print("Status: \(result.status)")
      print("Can request ads: \(result.canRequestAds)")
      print("Can show personalized ads: \(result.canShowPersonalizedAds)")

      if let error = result.error {
          print("Error: \(error)")
      }
  }
  ```

  ```objc Objective-C theme={null}
  [Adrop.consentManager requestConsentInfoUpdateFrom:self completion:^(AdropConsentResult *result) {
      NSLog(@"Status: %ld", (long)result.status);
      NSLog(@"Can request ads: %d", result.canRequestAds);
      NSLog(@"Can show personalized ads: %d", result.canShowPersonalizedAds);

      if (result.error != nil) {
          NSLog(@"Error: %@", result.error);
      }
  }];
  ```
</CodeGroup>

***

## 동의 상태

Consent Manager는 다음 상태 중 하나를 반환합니다:

| 상태            | 설명                |
| ------------- | ----------------- |
| `unknown`     | 동의 상태가 아직 결정되지 않음 |
| `required`    | 동의 필요 (팝업이 표시됨)   |
| `notRequired` | 동의 불필요 (비GDPR 지역) |
| `obtained`    | 이미 동의 완료됨         |

***

## 디버그 설정 (테스트 모드)

개발 중에 GDPR/CCPA 동의 흐름을 테스트하세요:

<CodeGroup>
  ```swift Swift theme={null}
  import AdropAds

  #if DEBUG
  // 동의 요청 전에 디버그 지역 설정
  Adrop.consentManager?.setDebugSettings(
      testDeviceIdentifiers: ["YOUR_DEVICE_IDENTIFIER"],  // Xcode 콘솔에서 확인
      geography: .EEA  // GDPR 테스트
  )

  // 테스트를 위한 동의 상태 리셋
  Adrop.consentManager?.reset()
  #endif
  ```

  ```objc Objective-C theme={null}
  @import AdropAds;

  #ifdef DEBUG
  // 동의 요청 전에 디버그 지역 설정
  [Adrop.consentManager setDebugSettingsWithTestDeviceIdentifiers:@[@"YOUR_DEVICE_IDENTIFIER"]
                                                        geography:AdropConsentDebugGeographyEEA];

  // 테스트를 위한 동의 상태 리셋
  [Adrop.consentManager reset];
  #endif
  ```
</CodeGroup>

### 디버그 지역

| 지역                 | 설명                  |
| ------------------ | ------------------- |
| `disabled`         | 실제 기기 위치 사용         |
| `EEA`              | GDPR 테스트 (유럽 경제 지역) |
| `regulatedUSState` | CCPA 테스트 (캘리포니아 등)  |
| `other`            | 규제가 없는 지역 테스트       |

<Warning>
  디버그 설정은 개발 중에만 사용해야 합니다. 프로덕션 배포 전에 제거하거나 비활성화하세요.
</Warning>

***

## 추가 메서드

| 메서드                  | 반환 타입                | 설명                           |
| -------------------- | -------------------- | ---------------------------- |
| `getConsentStatus()` | `AdropConsentStatus` | 현재 동의 상태를 반환합니다              |
| `canRequestAds()`    | `Bool`               | 동의 상태에 따라 광고 요청 가능 여부를 반환합니다 |
| `reset()`            | `Void`               | 동의 정보를 초기화합니다                |

```swift theme={null}
// 동의 상태 개별 확인
if let status = Adrop.consentManager?.getConsentStatus() {
    switch status {
    case .obtained:
        print("동의 완료")
    case .required:
        print("동의 필요")
    case .notRequired:
        print("동의 불필요")
    case .unknown:
        print("동의 상태 알 수 없음")
    }
}

// 광고 요청 가능 여부 확인
if Adrop.consentManager?.canRequestAds() == true {
    // 광고 로드
}

// 동의 정보 초기화 (테스트용)
Adrop.consentManager?.reset()
```

***

## 모범 사례

<CardGroup cols={2}>
  <Card title="조기 요청" icon="clock">
    SDK 초기화 직후, 앱 라이프사이클 초기에 동의를 요청하세요.
  </Card>

  <Card title="오류 처리" icon="triangle-exclamation">
    동의 오류를 적절히 처리하고 대체 동작을 제공하세요.
  </Card>

  <Card title="모든 시나리오 테스트" icon="vial">
    배포 전에 디버그 설정을 사용하여 모든 동의 시나리오를 테스트하세요.
  </Card>

  <Card title="사용자 선택 존중" icon="user-check">
    동의를 얻거나 거부된 후에는 사용자의 선택을 존중하고 반복적으로 요청하지 마세요.
  </Card>
</CardGroup>

***

## 관련 문서

<CardGroup cols={2}>
  <Card title="타겟팅" icon="bullseye" href="/ko/sdk/ios/targeting">
    사용자 및 문맥 타겟팅 설정
  </Card>

  <Card title="시작하기" icon="rocket" href="/ko/sdk/ios/overview">
    SDK 설치 및 설정 가이드
  </Card>

  <Card title="레퍼런스" icon="book" href="/ko/sdk/ios/reference">
    클래스, Delegate, 에러 코드
  </Card>
</CardGroup>
