Capacitor SDK 中的儿童模式

如果您的 Capacitor 应用面向儿童用户,您必须遵守 AppleGoogle 的相关政策。如果您正在使用 Adapty SDK,只需几个简单步骤即可完成配置,以满足这些政策要求并通过应用商店审核。

需要做什么?

您需要配置 Adapty SDK,禁止收集以下信息:

此外,我们建议谨慎使用自定义用户 ID。格式为 <FirstName.LastName> 的用户 ID 以及电子邮件地址,都会被视为收集个人数据。在儿童模式下,最佳实践是使用随机化或匿名化的标识符(例如哈希 ID 或设备生成的 UUID),以确保合规性。

启用儿童模式

在 Adapty 看板中进行更新

在 Adapty 看板中,您需要禁用 IP 地址收集。为此,请前往 App settings,然后在 Collect users’ IP address 下点击 Disable IP address collection

在您的移动应用代码中进行更新

为了符合相关政策,请禁用用户 IDFA、GAID 和 IP 地址的收集:

import { adapty } from '@adapty/capacitor';

try {
  await adapty.activate({
    apiKey: 'YOUR_PUBLIC_SDK_KEY',
    params: {
      // Disable IP address collection
      ipAddressCollectionDisabled: true,
      
      // Disable IDFA collection on iOS
      ios: {
        idfaCollectionDisabled: true
      },
      
      // Disable Google Advertising ID collection on Android
      android: {
        adIdCollectionDisabled: true
      }
    }
  });
  console.log('Adapty activated with Kids Mode enabled');
} catch (error) {
  console.error('Failed to activate Adapty with Kids Mode:', error);
}

平台特定配置

iOS:使用 CocoaPods 启用儿童模式

如果您在 iOS 上使用 CocoaPods,也可以在原生层面启用儿童模式:

  1. 更新您的 Podfile:

    • 如果您没有 post_install 部分,请添加以下完整代码块。
    • 如果您已有 post_install 部分,请将高亮行合并到其中。
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        if target.name == 'Adapty'
          target.build_configurations.each do |config|
            config.build_settings['OTHER_SWIFT_FLAGS'] ||= ['$(inherited)']
            config.build_settings['OTHER_SWIFT_FLAGS'] << '-DADAPTY_KIDS_MODE'
          end
        end
      end
    end
  2. 运行以下命令以应用更改:

    pod install 

Android:使用 Gradle 启用儿童模式

对于 Android,您也可以通过在应用的 build.gradle 中添加以下内容,在原生层面启用儿童模式:

android {
    defaultConfig {
        // ... existing config ...
        
        // Enable Kids Mode
        buildConfigField "boolean", "ADAPTY_KIDS_MODE", "true"
    }
}

后续步骤

启用儿童模式后,请确保:

  1. 全面测试您的应用,确保所有功能正常运行
  2. 更新应用的隐私政策,以反映已禁用的数据收集内容
  3. 在提交应用审核时,提供有关儿童模式合规性的清晰说明文档

有关平台特定要求的更多信息: