---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://ads.yandex.com/helpcenter/en/dev/ios/gdpr.md
  - https://ads.yandex.com/helpcenter/pt/dev/ios/gdpr.md
  - https://ads.yandex.com/helpcenter/ru/dev/ios/gdpr.md
  - https://ads.yandex.com/helpcenter/zh/dev/ios/gdpr.md
  - href: zh/dev/ios/gdpr.md
    type: text/markdown
    title: Markdown version
  - href: llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://ads.yandex.com/helpcenter/zh/llms.txt

# GDPR

 

## 一般信息 {#about}

<!-- source: zh/dev/_includes/gdpr-src.md -->
《通用数据保护条例》(GDPR) 于 2018 年春季生效。GDPR 规定了如何收集和处理有关欧洲经济区和瑞士公民的信息。其目的是保护机密数据的隐私，并确保与互联网上信息收集、存储和处理相关的所有流程的透明度。

GDPR 具有治外法权范围，适用于处理欧洲经济区和瑞士公民个人数据的所有公司，无论该公司位于何处。
<!-- endsource: zh/dev/_includes/gdpr-src.md -->

## 快速指南 {#instruction}

每次启动应用程序时，必须将用户同意处理个人数据的信息发送至 SDK。

1. 按照 [说明](https://ads.yandex.com/helpcenter/zh/dev/ios/quick-start.md) 连接 Mobile Ads SDK。

2. 显示一个窗口，用户可以在其中接受个人数据处理的用户协议（详情请参见 [示例](https://github.com/yandexmobile/yandex-ads-sdk-ios/tree/master/Examples/YandexMobileAdsExample/YandexMobileAdsExample/GDPR)）。

   {% note info %}

   此代码是一个示例，而不是要遵循的分步指南。

   {% endnote %}

   ```swift
   // ...
   // 创建对话框窗口的示例。

   func showGDPRDialog() {
       let alertController = UIAlertController(
           title: title,
           message: message,
           preferredStyle: .actionSheet)
       let acceptAction = UIAlertAction(
           title: "Accept",
           style: .default) { _ in
               self.setUserConsent(true)
           }
       alertController.addAction(acceptAction)
       let declineAction = UIAlertAction(
           title: "Decline",
           style: .default) { _ in
               self.setUserConsent(false)
           }
       alertController.addAction(declineAction)
       let openPrivacyPolicyAction = UIAlertAction(
           title: "View privacy policy",
           style: .default) { _ in
               UIApplication.shared.openURL(self.privacyPolicyURL)
           }
       alertController.addAction(openPrivacyPolicyAction)
       present(alertController, animated: true)
   }

   func setUserConsent(_ userConsent: Bool) {
       UserDefaults.standard.set(userConsent, forKey: kGDPRUserConsentKey)
   }

   func initializeAdsSDK() {
       let userConsent = UserDefaults.standard.bool(forKey: kGDPRUserConsentKey)
       MobileAds.setUserConsent(userConsent)
   }
   ```

3. 使用 `+ setUserConsent:` 方法将接收到的值传递至 Mobile Ads SDK。只有在用户同意数据处理的情况下，才会处理适用 GDPR 区域的用户的数据。

