시작하기

Google EU 사용자 동의 정책에 따라 영국과 유럽 경제 지역 (EEA) 사용자에게 특정 정보를 공개해야 하며, 법적으로 필요한 경우 쿠키 또는 기타 로컬 저장소를 사용하고 개인 정보 (예: AdID)를 사용하여 광고를 게재하기 위한 동의를 얻어야 합니다. 이 정책에는 EU 온라인 개인 정보 보호 지침 및 개인 정보 보호법 (GDPR)의 요구사항이 반영되어 있습니다.

게시자가 이 정책에 따른 의무를 이행할 수 있도록 Google은 사용자 메시지 플랫폼 (UMP) SDK를 제공합니다. UMP SDK는 최신 IAB 표준을 지원하도록 업데이트되었습니다. 이제 이 모든 구성이 개인 정보 보호 및 메시지에서 AdMob 편리하게 처리됩니다.

기본 요건

사용자 메시지 유형

지원되는 메시지의 전체 목록은 사용자 메시지 유형 을 참고하세요. 각 메시지 유형을 구현하는 방법에 관한 구체적인 안내는 왼쪽 탐색 메뉴를 참고하세요.

SDK 가져오기

CocoaPods (권장)

UMP SDK는 Google 모바일 광고 SDK 7.64.0부터 Google 모바일 광고 SDK 포드의 종속 항목으로 포함됩니다.

SDK를 iOS 프로젝트로 가져오는 가장 쉬운 방법은 CocoaPods를 사용하는 것입니다. 프로젝트의 Podfile을 열고 다음 행을 앱의 타겟에 추가하세요.

pod 'Google-Mobile-Ads-SDK'

그런 후 다음 명령어를 실행하세요.

pod install --repo-update

CocoaPods를 처음 사용하는 경우에는 CocoaPods 사용에서 Podfile을 만들고 사용하는 방법을 자세히 알아보세요.

수동 다운로드

SDK를 가져오는 다른 방법은 수동으로 수행하는 것입니다.

SDK 다운로드

그런 다음 프레임워크를 Xcode 프로젝트로 드래그하여 Copy items if needed(필요한 경우 항목 복사)를 선택합니다.

그러면 다음을 사용하여 필요한 모든 파일에 프레임워크를 포함할 수 있습니다.

Swift

import UserMessagingPlatform

Objective-C

#include <UserMessagingPlatform/UserMessagingPlatform.h>

Info.plist 업데이트

앱 ID 찾기 하여 Info.plist에 추가합니다.

<key>GADApplicationIdentifier</key>
<string>ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy</string>

메시지를 표시해야 하는지 결정

앱을 실행할 때마다 양식을 로드하기 전에 requestConsentInfoUpdateWithParameters:completionHandler: 를 사용하여 사용자 동의 정보 업데이트를 요청해야 합니다. 이를 통해 사용자가 아직 동의를 제공하지 않았거나 동의가 만료된 경우 동의를 제공해야 하는지 여부를 판단할 수 있습니다.

필요한 경우 나중에 양식을 발표할 수 있습니다.

다음은 앱 시작 시 상태를 확인하는 방법의 예입니다.

Swift

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
   // Create a UMPRequestParameters object.
   let parameters = UMPRequestParameters()
   // Set tag for under age of consent. Here false means users are not under age.
   parameters.tagForUnderAgeOfConsent = false

   // Request an update to the consent information.
   UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(
      with: parameters,
      completionHandler: { error in
        if error != nil {
           // Handle the error.
        } else {
           // The consent information state was updated.
           // You are now ready to check if a form is
           // available.
        }
       })
}

Objective-C

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

// Create a UMPRequestParameters object.
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
// Set tag for under age of consent. Here NO means users are not under age.
parameters.tagForUnderAgeOfConsent = NO;

// Request an update to the consent information.
[UMPConsentInformation.sharedInstance
    requestConsentInfoUpdateWithParameters:parameters
                         completionHandler:^(NSError *_Nullable error) {
                           if (error) {
                             // Handle the error.
                           } else {
                             // The consent information state was updated.
                             // You are now ready to check if a form is
                             // available.
                           }
                         }];
}

가능한 경우 양식 로드

양식을 표시하기 전에 먼저 양식을 사용할 수 있는지 확인해야 합니다. 사용할 수 없는 양식은 사용자가 제한된 광고 추적을 사용 설정했거나 사용자가 동의 연령 미만인 사용자로 태그를 지정했기 때문일 수 있습니다.

양식의 사용 가능 여부를 확인하려면 앞서 만든the formStatus property on the UMPConsentInformation instance 를 사용하세요.

그런 다음 래퍼 메서드를 추가하여 양식을 로드합니다.

Swift

// Request an update to the consent information.
UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(
    withParameters: parameters,
    completionHandler: { [self] error in

      // The consent information has updated.
      if error != nil {
        // Handle the error.
      } else {
        // The consent information state was updated.
        // You are now ready to see if a form is available.
        let formStatus = UMPConsentInformation.sharedInstance.formStatus
        if formStatus == UMPFormStatus.available {
          loadForm()
        }
      }
    })
...
func loadForm() {

}

Objective-C

// Request an update to the consent information.
[UMPConsentInformation.sharedInstance
    requestConsentInfoUpdateWithParameters:parameters
                         completionHandler:^(NSError* _Nullable error) {

                           // The consent information has updated.
                           if (error) {
                             // Handle the error.
                           } else {
                             // The consent information state was updated.
                             // You are now ready to see if a form is available.
                             UMPFormStatus formStatus =
                                 UMPConsentInformation.sharedInstance
                                     .formStatus;
                             if (formStatus == UMPFormStatusAvailable) {
                               [self loadForm];
                             }
                           }
                         }];
...
- (void) loadForm {

}

양식을 로드하려면 the static loadWithCompletionHandler: method on the UMPConsentForm class를 사용합니다.

Swift

func loadForm() {
  // Loads a consent form. Must be called on the main thread.
  UMPConsentForm.load(
      withCompletionHandler: { form, loadError in
        if loadError != nil {
          // Handle the error
        } else {
          // Present the form
        }
      })
}

Objective-C

- (void)loadForm {
  [UMPConsentForm
      loadWithCompletionHandler:^(UMPConsentForm *form, NSError *loadError) {
        if (loadError) {
          // Handle the error
        } else {
          // Present the form
        }
      }];
}

필요한 경우 양식 제공

양식의 사용 가능 여부를 확인하고 양식을 로드한 후에는UMPConsentForm 인스턴스에서presentFromViewController:completionHandler: 메서드를 사용하여 양식을 표시합니다.

앞에서UMPConsentInformation 객체를 사용하여consent status 를 확인하고loadForm 메서드를 업데이트합니다.

Swift

func loadForm() {
  UMPConsentForm.load(withCompletionHandler: { form, loadError in
    if loadError != nil {
      // Handle the error.
    } else {
      // Present the form. You can also hold on to the reference to present
      // later.
      if UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatus.required {
        form?.present(
            from: self,
            completionHandler: { dismissError in
              if UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatus.obtained {
                // App can start requesting ads.
              }
                // Handle dismissal by reloading form.
                loadForm();
            })
      } else {
        // Keep the form available for changes to user consent.
      }
    }
  })
}

Objective-C

- (void)loadForm {
  [UMPConsentForm loadWithCompletionHandler:^(UMPConsentForm *form,
                                              NSError *loadError) {
    if (loadError) {
      // Handle the error.
    } else {
      // Present the form. You can also hold on to the reference to present
      // later.
      if (UMPConsentInformation.sharedInstance.consentStatus ==
          UMPConsentStatusRequired) {
        [form
            presentFromViewController:self
                    completionHandler:^(NSError *_Nullable dismissError) {
                      if (UMPConsentInformation.sharedInstance.consentStatus ==
                          UMPConsentStatusObtained) {
                        // App can start requesting ads.
                      }
                        // Handle dismissal by reloading form.
                        [self loadForm];
                    }];
      } else {
        // Keep the form available for changes to user consent.
      }
    }
  }];
}

사용자가 선택했거나 양식을 닫은 후에 작업을 실행해야 하는 경우 이 로직을 양식의 완료 핸들러 또는 콜백에 배치합니다.

테스트

지역 강제 설정

UMP SDK는 the debugGeography property of type UMPDebugGeography on UMPDebugSettings를 사용하여 기기가 EEA 또는 영국에 있는 것처럼 앱 동작을 테스트할 수 있는 방법을 제공합니다.

디버그 기능을 사용하려면 앱의 디버그 설정에 테스트 기기의 해시 ID를 제공해야 합니다. 이 값을 설정하지 않고requestConsentInfoUpdateWithParameters:completionHandler: 를 호출하면 실행 시 앱에서 필수 ID 해시를 로깅합니다.

Swift

let parameters = UMPRequestParameters()
let debugSettings = UMPDebugSettings()
debugSettings.testDeviceIdentifiers = ["TEST-DEVICE-HASHED-ID"]
debugSettings.geography = UMPDebugGeography.EEA
parameters.debugSettings = debugSettings
UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(
    with: parameters,
    completionHandler: { error in
      ...
    })

Objective-C

UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
debugSettings.testDeviceIdentifiers = @[ @"TEST-DEVICE-HASHED-ID" ];
debugSettings.geography = UMPDebugGeographyEEA;
parameters.debugSettings = debugSettings;
[UMPConsentInformation.sharedInstance
    requestConsentInfoUpdateWithParameters:parameters
                         completionHandler:^(NSError *_Nullable error){
                           ...
}];

UMPDebugGeography를 사용하면 지역을 다음 옵션 중 하나로 강제 설정할 수 있습니다.

디버그 지리 설명
UMPDebugGeographyDisabled 디버그 지역을 사용 중지했습니다.
UMPDebugGeographyEEA 디버그 기기에 대해 지역이 EEA로 표시됩니다.
UMPDebugGeographyNotEEA 디버그 기기에 대해 지역이 EEA가 아닌 것으로 표시됩니다.

디버그 설정은 테스트 기기에서만 작동합니다. 에뮬레이터는 기본적으로 테스트가 이미 사용 설정되어 있으므로 기기 ID 목록에 추가할 필요가 없습니다.

UMP SDK로 앱을 테스트할 때 사용자의 첫 설치 경험을 시뮬레이션할 수 있도록 SDK 상태를 재설정하면 도움이 될 수 있습니다. SDK는 이를 위한 reset 메서드를 제공합니다.

Swift

UMPConsentInformation.sharedInstance.reset()

Objective-C

[UMPConsentInformation.sharedInstance reset];

UMP SDK를 프로젝트에서 완전히 삭제하기로 결정한 경우에도 reset 를 호출해야 합니다.