Flutter SDK 中的儿童模式
如果您的 Flutter 应用面向儿童,则必须遵守 Apple 和 Google 的相关政策。如果您正在使用 Adapty SDK,只需几个简单步骤即可将其配置为符合这些政策,并顺利通过应用商店审核。
需要做什么?
你需要配置 Adapty SDK 以禁止收集以下信息:
- IDFA(广告主标识符)(iOS)
- Android 广告 ID(AAID/GAID)(Android)
- IP 地址
此外,我们建议谨慎使用 customer user ID。以
<FirstName.LastName>格式设置的 User ID 与使用邮箱地址一样,会被认定为收集个人数据。在儿童模式下,最佳做法是使用随机化或匿名化的标识符(例如哈希 ID 或设备生成的 UUID),以确保合规。
启用儿童模式
在 Adapty 看板中进行更新
在 Adapty 看板中,您需要禁用 IP 地址收集。为此,请前往 App settings,然后在 Collect users’ IP address 下点击 Disable IP address collection。
更新您的移动应用代码
为了遵守相关政策,请禁用用户 IDFA(iOS)、GAID/AAID(Android)以及 IP 地址的收集。
Android:更新 SDK 配置
try {
await Adapty().activate(
configuration: AdaptyConfiguration(apiKey: 'YOUR_API_KEY')
..withGoogleAdvertisingIdCollectionDisabled(true), // set to `true`
..withIpAddressCollectionDisabled(true), // set to `true`
);
} catch (e) {
// handle the error
}
iOS:使用 CocoaPods 启用 Kids Mode
-
更新你的 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 post_install do |installer| # ... 保留你现有的 post_install 内容(Flutter 会自动添加一个)... adapty_enable_kids_mode(installer) # <-- 启用 Adapty 儿童模式 end - 如果你没有
-
运行以下命令使更改生效
pod install