UIEventAttribution

Panther·2021년 10월 7일
0

https://developer.apple.com/documentation/uikit/uieventattribution

"An object that contains event attribution information for Private Click Measurement."

Private Click Measurement에 대한 이벤트 특성 정보를 포함하는 객체입니다.

Declaration

@MainActor class UIEventAttribution : NSObject

Overview

앱은 Private Click Measurement(PCM)를 지원하는 외부 웹사이트를 열 때 브라우저에 데이터를 전달하기 위한 이벤트 특성 객체를 사용합니다. 목적이 있는 PCM 웹 표준에 대한 더 많은 정보는 Introducing Private Click Measurement 및 Private Click Measurement Draft Community Group Report를 보시기 바랍니다.

Introducing Private Click Measurement
https://webkit.org/blog/11529/introducing-private-click-measurement-pcm/

Private Click Measurement Draft Community Group Report
https://privacycg.github.io/private-click-measurement/

Note
맥 Catalyst로 빌드된 맥 앱은 PCM을 지원하지 않습니다.

UIEventAttribution은 서브클래싱할 수 없습니다.

Define an Endpoint

PCM을 사용하려면 앱은 브라우저가 이벤트 특성 데이터를 보내는 URL을 포함하고 있는 NSAdvertisingAttributionReportEndpoint Info.plist 키를 정의합니다. 외부로 링크된 웹사이트가 컨버전이 발생했다고 보고하는 경우 브라우저는 Info.plist에서 구체화된 엔드포인트로 앱의 이벤트 특성 데이터를 전달합니다. 앱의 Info.plist가 이 키를 포함하지 않으면 브라우저는 전환이 발생했을 때 PCM 데이터를 전달할 수 없을 것입니다.

사용자가 앱 뷰 계층구조에서 UIEventAttributionView 아래에 놓인 컨트롤을 탭해서 외부 링크를 열 때에만 브라우저로 이벤트 특성 데이터를 전달해야 합니다. 이벤트 특성 뷰는 사용자가 컨트롤을 탭햇음을 검증합니다. 해당 컨트롤이 이벤트 특성 뷰 아래에 놓여잇지 않은 경우 시스템은 외부 링크를 열 때 브라우저에게 PCM 데이터를 전달하지 않을 것입니다.

Create an Event Attribution Data Object

아래는 UIEventAttribution 객체를 생성하는 방법입니다.

let adURL = URL(string: "https://shop.example/tabletStandDeluxe.html")!
let eventAttribution =
    UIEventAttribution(sourceIdentifier: 4,
                       destinationURL: adURL,
                       sourceDescription: "Banner ad for Tablet Stand Deluxe.",
                       purchaser: "Shop Example, Inc.")

Include Event Attribution Data

UIEventAttribution 객체를 생성한 후 앱이 사용자의 탭에 의한 URL을 열 때 브라우저에게 이 객체를 보내야 합니다. 외부 웹사이트가 일주일 내 전환을 보고하는 경우 브라우저는 전환 이후 24~48 시간 사이에 구체화된 원격 서버로 UIEventAttribution 객체로부터의 데이터를 전달합니다.

앱이 외부 링크를 열 때 이벤트 특성 데이터를 전달하는 두 가지 방법이 있으며, 앱이 생명주기 관리에서 UIScene 혹은 UIApplication을 사용하느냐에 따라 달라집니다. 애플리케이션 생애주기 관리에 대한 더 많은 정보는 Managing Your App's Life Cycle을 보시기 바랍니다.

Managing Your App's Life Cycle
https://developer.apple.com/documentation/uikit/app_and_environment/managing_your_app_s_life_cycle
https://velog.io/@panther222128/App-Life-Cycle

Important
앱이 아니라 브라우저가 원격 서버에 이벤트 특성 데이터를 전달합니다. 사용자의 선택된 브라우저가 PCM을 지원하지 않는 경우 이벤트 특성은 외부 웹사이트가 전환을 알릴지라도 실패하게 됩니다.

앱이 UIScene 기반 생명주기 관리를 사용하는 경우 UIScene.OpenExternalURLOptions 객체를 생성하고, 생성한 이벤트 특성 객체를 이 객체의 eventAttribution 속성에 할당해야 하며, open(_:options:completionHandler:)를 호출해야 합니다.

let sceneOpenURLOptions = UIScene.OpenExternalURLOptions()
sceneOpenURLOptions.eventAttribution = eventAttribution

self.view.window?.windowScene?.open(adURL,
                                    options: sceneOpenURLOptions,
                                    completionHandler: nil)
If your app uses UIApplication-based life cycle management, create a dictionary that contains the eventAttribution key with the UIEventAttribution object you created as its value, and call open(_:options:completionHandler:), passing the dictionary using the options parameter.

let appOpenURLOptions: [UIApplication.OpenExternalURLOptionsKey : Any] = [
    .eventAttribution: eventAttribution
]
UIApplication.shared.open(adURL,
                          options: appOpenURLOptions,
                          completionHandler: nil)

See Also


Private Click Measurement (PCM)

UIEventAttributionView

Private Click Measurement에서 사용자 상호작용 검증을 하는 오버레이 뷰입니다.

https://developer.apple.com/documentation/uikit/uieventattributionview
https://velog.io/@panther222128/UIEventAttributionView


0개의 댓글