---
title: "Chế độ Trẻ em trong Flutter SDK"
description: "Dễ dàng bật Chế độ Trẻ em để tuân thủ chính sách của Apple và Google. Không thu thập IDFA, GAID hay dữ liệu quảng cáo trong Flutter SDK."
---

Nếu ứng dụng Flutter của bạn dành cho trẻ em, bạn phải tuân thủ chính sách của [Apple](https://developer.apple.com/kids/) và [Google](https://support.google.com/googleplay/android-developer/answer/9893335). Nếu đang sử dụng Adapty SDK, bạn chỉ cần thực hiện vài bước đơn giản để cấu hình SDK đáp ứng các chính sách này và vượt qua quá trình xét duyệt của cửa hàng ứng dụng.

## Cần làm gì? \{#whats-required\}

Bạn cần cấu hình Adapty SDK để tắt việc thu thập:

- [IDFA (Identifier for Advertisers)](https://en.wikipedia.org/wiki/Identifier_for_Advertisers) (iOS)
- [Android Advertising ID (AAID/GAID)](https://support.google.com/googleplay/android-developer/answer/6048248) (Android)
- [Địa chỉ IP](https://www.ftc.gov/system/files/ftc_gov/pdf/p235402_coppa_application.pdf)

Ngoài ra, hãy cẩn thận khi sử dụng customer user ID. ID người dùng có định dạng `<TênĐệm.Họ>` sẽ bị coi là thu thập dữ liệu cá nhân, tương tự như sử dụng email. Với Chế độ Trẻ em, cách làm tốt nhất là dùng các định danh ngẫu nhiên hoặc ẩn danh (ví dụ: ID đã băm hoặc UUID do thiết bị tạo) để đảm bảo tuân thủ.

## Bật Chế độ Trẻ em \{#enabling-kids-mode\}

### Cập nhật trong Adapty Dashboard \{#updates-in-the-adapty-dashboard\}

Trong Adapty Dashboard, bạn cần tắt tính năng thu thập địa chỉ IP. Để thực hiện, vào [App settings](https://app.adapty.io/settings/general) và nhấn **Disable IP address collection** trong phần **Collect users' IP address**.

### Cập nhật trong code ứng dụng di động \{#updates-in-your-mobile-app-code\}

Để tuân thủ chính sách, hãy tắt việc thu thập IDFA của người dùng (cho iOS), GAID/AAID (cho Android) và địa chỉ IP.

**Android: Cập nhật cấu hình SDK**

```dart showLineNumbers title="Dart"
try {
    await Adapty().activate(
        configuration: AdaptyConfiguration(apiKey: 'YOUR_API_KEY')
      // highlight-start
          ..withGoogleAdvertisingIdCollectionDisabled(true),  // set to `true`
          ..withIpAddressCollectionDisabled(true),  // set to `true`
      // highlight-end
    );
} catch (e) {
    // handle the error
}
```

**iOS: Bật Chế độ Trẻ em bằng CocoaPods**

1. Cập nhật Podfile của bạn:

   - Nếu bạn **chưa có** phần `post_install`, hãy thêm toàn bộ khối code bên dưới.
   - Nếu bạn **đã có** phần `post_install`, hãy hợp nhất các dòng được đánh dấu vào đó.

    ```ruby showLineNumbers title="Podfile"
    def adapty_enable_kids_mode(installer)
      installer.pods_project.targets.each do |target|
        next unless target.name == 'Adapty'
        target.build_configurations.each do |config|
          flags = config.build_settings['OTHER_SWIFT_FLAGS'] || '$(inherited)'
          flags = flags.join(' ') if flags.is_a?(Array)
          config.build_settings['OTHER_SWIFT_FLAGS'] = "#{flags} -DADAPTY_KIDS_MODE"
        end
        target.frameworks_build_phase.files.dup.each do |bf|
          target.frameworks_build_phase.remove_build_file(bf) if bf.display_name.to_s.include?('AdSupport')
        end
      end
      installer.pods_project.save
      Dir.glob(File.join(installer.sandbox.root, 'Target Support Files', '**', '*.xcconfig')).each do |xc|
        File.write(xc, File.read(xc).gsub(/\s*-framework\s+"?AdSupport"?/, ''))
      end
    end

    post_install do |installer|
      # ... keep your existing post_install body (Flutter adds one automatically) ...

      adapty_enable_kids_mode(installer)   # <-- enable Adapty Kids Mode
    end
    ```

2. Áp dụng các thay đổi bằng cách chạy

    ```sh showLineNumbers title="Shell"
    pod install
    ```