Capacitor SDK 中的儿童模式
如果您的 Capacitor 应用面向儿童用户,您必须遵守 Apple 和 Google 的相关政策。如果您正在使用 Adapty SDK,只需几个简单步骤即可完成配置,以满足这些政策要求并通过应用商店审核。
需要做什么?
你需要配置 Adapty SDK,禁止收集以下信息:
- IDFA(广告标识符)(iOS)
- Android 广告 ID(AAID/GAID)(Android)
- IP 地址
此外,我们建议谨慎使用 customer user ID。以
<FirstName.LastName>格式设置的用户 ID 与使用邮箱地址一样,都会被视为收集个人数据。在儿童模式下,最佳实践是使用随机或匿名的标识符(例如哈希 ID 或设备生成的 UUID),以确保合规。
启用儿童模式
在 Adapty 看板中进行更新
在 Adapty 看板中,您需要禁用 IP 地址收集。为此,请前往 App settings,然后在 Collect users’ IP address 下点击 Disable IP address collection。
在移动应用代码中进行更新
为遵守相关政策,请禁止收集用户的 IDFA、GAID 和 IP 地址:
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,也可以在原生层面启用儿童模式:
-
更新你的 Podfile:
- 如果你没有
post_install部分,请添加下方完整代码块。 - 如果你已有
post_install部分,请将高亮行合并进去。
- 如果你没有
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
```groovy showLineNumbers title="build.gradle"
android {
defaultConfig {
manifestPlaceholders = [AdaptyKidsMode: "true"]
}
}
-
运行以下命令应用更改:
pod install
Android:使用 Gradle 启用儿童模式
对于 Android,你也可以通过在应用的 build.gradle 中添加以下内容,在原生层启用儿童模式:
android {
defaultConfig {
// ... existing config ...
// Enable Kids Mode
buildConfigField "boolean", "ADAPTY_KIDS_MODE", "true"
}
}
后续步骤
启用儿童模式后,请确保:
- 全面测试您的应用,确保所有功能正常运行
- 更新应用的隐私政策,反映已禁用数据收集的情况
- 提交应用审核时,附上关于儿童模式合规性的清晰说明
有关各平台具体要求的更多信息,请参阅:
- iOS SDK 中的儿童模式:iOS 配置详情
- Android SDK 中的儿童模式:Android 配置详情