隐私清单

了解如何为你的移动应用配置 iOS 隐私清单。


如果你正在使用调用“受限原因”API的原生iOS库,你需要配置iOS隐私清单,以说明为何你包含原生代码来调用这些API。

🌐 If you're using a native iOS library that uses a "restricted reason" APIs, you'll need to configure an iOS privacy manifest to declare why you're including native code to call those APIs.

更多详细信息以及“必要理由”API的列表,请参阅 Apple 开发者文档

🌐 More details and a list of "required reason" APIs can be found in the Apple Developer Documentation.

信息 本指南中包含的信息和步骤仍在开发中,可能会因为为此目的开发的新工具或苹果公司提出的新要求而发生变化。

什么是隐私清单?

🌐 What is a Privacy manifest?

隐私清单是一个名为 PrivacyInfo.xcprivacy 的文件,包含在你的 iOS 原生项目中。该文件用于声明应用包含调用 Apple 认为敏感的某些 API 的原生代码的原因。

🌐 A privacy manifest is a file named PrivacyInfo.xcprivacy that is included in your iOS native project. This file is used to declare why the app includes native code that calls into certain APIs that Apple considers sensitive.

这些 API 目前包括访问 UserDefaults、文件时间戳、系统启动时间、磁盘空间以及活动键盘。苹果认为这是一个开放列表,将来可能会扩展。

🌐 These APIs currently include accessing UserDefaults, file timestamp, system boot time, disk space, and active keyboard. Apple considers it an open list that can be expanded in the future.

应用配置中的配置

🌐 Configuration in app config

你可以通过在应用配置中的 expo.ios 下使用 privacyManifests 字段来包含 iOS 隐私声明。

🌐 You can include an iOS privacy manifest by using the privacyManifests field under expo.ios in your app config.

app.json
{ "expo": { "name": "My App", "slug": "my-app", %%placeholder-start%%... %%placeholder-end%% "ios": { "privacyManifests": { "NSPrivacyAccessedAPITypes": [ { "NSPrivacyAccessedAPIType": "NSPrivacyAccessedAPICategoryUserDefaults", "NSPrivacyAccessedAPITypeReasons": ["CA92.1"] } ] } } } }

请确保使用 npx expo install --fix 将你的 Expo SDK 库更新到对应 SDK 版本的最新版本。

🌐 Make sure you have updated your Expo SDK libraries to the latest versions for your SDK version using npx expo install --fix.

Are you using this library in an existing React Native app?

你可以通过使用 Xcode 创建一个 PrivacyInfo.xcprivacy 文件并将其添加到你的 iOS 应用目标中,在裸 Expo 应用中包含 iOS 隐私清单。请按照 Apple 的隐私清单文件 指南创建 PrivacyInfo.xcprivacy 文件。

🌐 You can include an iOS privacy manifest in a bare Expo app by creating a PrivacyInfo.xcprivacy file using Xcode and adding it to your iOS app target. Follow Apple's Privacy manifest files guide to create a PrivacyInfo.xcprivacy file.

你可以通过查看 Apple 开发者文档 来确定 NSPrivacyAccessedAPITypesNSPrivacyAccessedAPITypeReasons 的值。

🌐 You can identify the NSPrivacyAccessedAPITypes and NSPrivacyAccessedAPITypeReasons values by looking at the Apple Developer documentation.

包括 Expo SDK 包和其他第三方库所需的原因

🌐 Including required reasons for Expo SDK packages and other third-party libraries

截至目前,Apple 并不能正确解析所有由静态 CocoaPods 依赖(例如 Expo SDK 包和其他生态系统库)包含的 PrivacyInfo 文件。你可能需要在应用的 PrivacyInfo.xcprivacy 文件中,或者在 app.json 配置中,包含这些依赖所使用的 API 的必要原因。

🌐 As of now, Apple does not correctly parse all the PrivacyInfo files included by static CocoaPods dependencies (such as Expo SDK packages and other ecosystem libraries). You may need to include the required reasons for the APIs used by those dependencies in your app's PrivacyInfo.xcprivacy file or the configuration in the app.json.

所有使用“必需原因”API文件的 Expo SDK 包在包目录中都包含一个 PrivacyInfo 文件。这里有一个随 expo-application 库一起包含的 示例文件

🌐 All Expo SDK packages that use "required reason" APIs file have a PrivacyInfo file included in the package directory. Here's an example file included with the expo-application library.

通常,你可以通过检查你打算使用的库在 node_modules/package_name/ios 目录下是否有 PrivacyInfo.xcprivacy 文件来识别其他第三方库使用的 API 所需的原因。如果有,你可以查看该文件中的 NSPrivacyAccessedAPITypesNSPrivacyAccessedAPITypeReasons 值,并将这些值复制到你的配置中。

🌐 You can usually identify the required reasons for the APIs used by other third-party libraries by checking if the library you intend to use has a PrivacyInfo.xcprivacy file in the node_modules/package_name/ios directory. If it does, you can check the NSPrivacyAccessedAPITypes and NSPrivacyAccessedAPITypeReasons values in that file and copy those values to your configuration.

作为替代方案,Apple 会在开发者提交的版本中缺少隐私声明文件或存在特定原因时向开发者发送通知。你可以等待收到 Apple 的通知邮件,然后在应用的 PrivacyInfo.xcprivacy 文件中包含邮件中列出的必要原因(如果你不使用 CNG),或在 app.json 文件中进行配置。

🌐 As an alternative, Apple notifies developers after they submit a build with missing privacy manifest files or specific reasons. You can wait until you receive a notification email from Apple and then include the required reasons listed in the email in your app's PrivacyInfo.xcprivacy file (if you don't use CNG) or the configuration in your app.json file.

测试隐私清单

🌐 Testing the Privacy manifest

你可以通过构建应用并提交它来测试隐私声明,无论是通过 App Store 审核流程,还是提交给 TestFlight 的外部审核。如果你的应用缺少使用某些 API 的必要原因,Apple 会在你提交后几分钟内通过电子邮件通知你。

🌐 You can test the privacy manifest by building your app and submitting it, either through App Store review process or to TestFlight's external review. Apple will email you within a few minutes of submitting if your app is missing any required reasons for the APIs used.