This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo TrackingTransparency
一个用于跟踪应用用户和管理跟踪权限的库。
一个用于跟踪应用用户和管理跟踪权限的库。提供对广告标识符的访问,并管理跟踪所需的权限。用于跟踪的数据示例包括电子邮件地址、设备ID、广告ID等。如果设备级设置“允许应用请求跟踪”关闭,该权限将被拒绝。请确保在你的 Info.plist 中添加 NSUserTrackingUsageDescription 来说明用户将如何被跟踪。否则,你的应用将被苹果拒绝。
🌐 A library for tracking app users and managing tracking permissions. Provides access to advertising identifiers and manages the required permissions for tracking. Examples of data used for tracking include email address, device ID, advertising ID, and more. If the "Allow Apps to Request to Track" device-level setting is off, this permission will be denied. Be sure to add NSUserTrackingUsageDescription to your Info.plist to explain how the user will be tracked. Otherwise, your app will be rejected by Apple.
有关苹果应用追踪透明度框架的更多信息,请参阅他们的文档。
🌐 For more information on Apple's App Tracking Transparency framework, see their documentation.
安装
🌐 Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
应用配置中的配置
🌐 Configuration in app config
如果你在项目中使用配置插件(连续原生生成 (CNG)),可以使用其内置的 配置插件 来配置 expo-tracking-transparency。该插件允许你配置无法在运行时设置并且需要构建新的应用二进制文件才能生效的各种属性。如果你的应用不使用 CNG,则需要手动配置该库。
🌐 You can configure expo-tracking-transparency using its built-in config plugin if you use config plugins in your project (Continuous Native Generation (CNG)). The plugin allows you to configure various properties that cannot be set at runtime and require building a new app binary to take effect. If your app does not use CNG, then you'll need to manually configure the library.
Example app.json with config plugin
Configurable properties
要本地化这个 iOS 权限提示信息,保持 userTrackingPermission 为默认值,并将 NSUserTrackingUsageDescription 添加到每个 locale 文件 的 ios 对象中。Expo 会在预构建期间将本地化的值写入 InfoPlist.strings。
🌐 To localize this iOS permission message, keep userTrackingPermission as the default value and add NSUserTrackingUsageDescription to the ios object in each locale file. Expo writes the localized values to InfoPlist.strings during prebuild.
Are you using this library in an existing React Native app?
如果你没有使用连续原生生成(CNG)(而是手动使用原生 Android 和 iOS 项目),那么你需要在原生项目中配置以下权限:
🌐 If you're not using Continuous Native Generation (CNG) (you're using native android and ios projects manually), then you need to configure following permissions in your native projects:
-
对于 Android,请在项目的 android/app/src/main/AndroidManifest.xml 中添加
com.google.android.gms.permission.AD_ID权限。<uses-permission android:name="com.google.android.gms.permission.AD_ID"/> -
对于 iOS,在你的项目 ios/[app]/Info.plist 中添加
NSUserTrackingUsageDescription键:<key>NSUserTrackingUsageDescription</key> <string>Your custom usage description string here.</string>
用法
🌐 Usage
应用接口
🌐 API
import * as ExpoTrackingTransparency from 'expo-tracking-transparency';
No API data file found, sorry!
权限
🌐 Permissions
安卓
🌐 Android
以下权限会通过库的 AndroidManifest.xml 自动添加。
🌐 The following permissions are added automatically through the library's AndroidManifest.xml.
iOS
该库使用以下用法描述键:
🌐 The following usage description keys are used by this library: