@capgo/capacitor-app-tracking-transparency

中文文档
8.1.21发布于 2026/10/15MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 3.4万

Capacitor plugin for iOS App Tracking Transparency framework. Request user authorization to access app-related data for tracking.

原始使用文档
文档目录16 节
  1. ➡️ Get started for free
  2. Key features
  3. Why Capacitor App Tracking Transparency?
  4. Documentation
  5. Compatibility
  6. Install
  7. iOS
  8. Localizing the Permission Message
  9. Android
  10. Web
  11. API
  12. getStatus()
  13. requestPermission()
  14. getPluginVersion()
  15. Interfaces
  16. Type Aliases

capacitor-app-tracking-transparency

Show Apple's App Tracking Transparency prompt and read the user's choice from your Capacitor app. Required before you access the IDFA for ads or attribution on iOS.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-app-tracking-transparency in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-app-tracking-transparency to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-app-tracking-transparency for Capacitor apps

Key features

  • Request permission: requestPermission() shows the iOS tracking prompt and returns the result.
  • Read status: getStatus() returns the current authorization without prompting.
  • Native framework: uses Apple's AppTrackingTransparency framework.
  • Simple states: authorized, denied, restricted or not determined.
  • Platforms: iOS, Android and Web. The prompt is iOS only. On Android and web, requestPermission() and getStatus() return authorized without prompting.

Why Capacitor App Tracking Transparency?

A simple, free, and lightweight plugin for iOS App Tracking Transparency:

  • iOS 14+ compliance - Handle Apple's App Tracking Transparency requirements
  • Permission status - Check current authorization status without prompting
  • Request permission - Display the native iOS permission dialog
  • Cross-platform - Returns authorized on Android/Web for transparent usage
  • Modern package management - Supports both Swift Package Manager (SPM) and CocoaPods (SPM-ready for Capacitor 8)
  • Zero dependencies - Minimal footprint, no bloat

Perfect for apps using IDFA, advertising SDKs, analytics tracking, or any feature that tracks users across apps and websites.

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/app-tracking-transparency/

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅
v7.*.*v7.*.*On demand
v6.*.*v6.*.*❌
v5.*.*v5.*.*❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-app-tracking-transparency` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-app-tracking-transparency
npx cap sync

iOS

Add the NSUserTrackingUsageDescription key to your Info.plist file:

<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>

The string should explain why you need tracking permission. This message will be displayed to users when requesting permission.

Localizing the Permission Message

To provide localized versions of the tracking permission message, create InfoPlist.strings files for each language:

  1. Create a InfoPlist.strings file in your Xcode project
  2. Add the NSUserTrackingUsageDescription key with a localized value:
"NSUserTrackingUsageDescription" = "This identifier will be used to deliver personalized ads to you.";

Android

App Tracking Transparency is an iOS-only framework. This plugin returns authorized status on Android to allow transparent cross-platform usage without conditional code.

Web

Returns authorized status on Web for development purposes and transparent cross-platform usage.

API

Capacitor App Tracking Transparency Plugin.

A plugin to request and check user authorization for app tracking on iOS devices. Uses Apple's App Tracking Transparency framework.

getStatus()

getStatus() => Promise<AppTrackingStatusResponse>

Gets the current tracking authorization status without prompting the user.

Returns: Promise<AppTrackingStatusResponse>

Since: 1.0.0


requestPermission()

requestPermission() => Promise<AppTrackingStatusResponse>

Requests user authorization to access app-related data for tracking. Displays the native iOS tracking permission dialog.

Note: This method will only show the dialog once. Subsequent calls will return the stored authorization status without showing the dialog.

Returns: Promise<AppTrackingStatusResponse>

Since: 1.0.0


getPluginVersion()

getPluginVersion() => Promise<{ version: string; }>

Get the native Capacitor plugin version.

Returns: Promise<{ version: string; }>

Since: 1.0.0


Interfaces

AppTrackingStatusResponse

Response object containing the tracking authorization status.

PropTypeDescriptionSince
statusAppTrackingStatusThe current tracking authorization status.1.0.0

Type Aliases

AppTrackingStatus

Possible values for the tracking authorization status.

  • authorized: User has authorized access to app-related data for tracking
  • denied: User has denied access to app-related data for tracking
  • notDetermined: User has not yet received the authorization request
  • restricted: Authorization is restricted (e.g., parental controls, MDM)

'authorized' | 'denied' | 'notDetermined' | 'restricted'

版本与发布记录

@capgo/capacitor-app-tracking-transparency 共发布 22 个版本,首次发布于 2026/02/01;过去 12 个月发布了 22 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.1.21latest2026/10/1525 天前
8.1.202026/10/1327 天前
8.1.192026/10/091 个月前
8.1.182026/10/081 个月前
8.1.172026/10/081 个月前
8.1.162026/09/161 个月前

关于 @capgo/capacitor-app-tracking-transparency 的常见问题

@capgo/capacitor-app-tracking-transparency 是什么?

Capacitor plugin for iOS App Tracking Transparency framework. Request user authorization to access app-related data for tracking.

如何安装 @capgo/capacitor-app-tracking-transparency?

在项目目录运行 npm install @capgo/capacitor-app-tracking-transparency,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-app-tracking-transparency 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-app-tracking-transparency 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-app-tracking-transparency 可以商用吗?

@capgo/capacitor-app-tracking-transparency 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-app-tracking-transparency 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-app-tracking-transparency 在 2026/10/09 – 2026/11/07 这 30 天内被下载 33,544 次,日均约 1,118 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-app-tracking-transparency 还在维护吗?

最新版本 8.1.21 发布于 2026/10/15(25 天前);至今共发布 22 个版本,其中过去 12 个月发布了 22 个;首次发布于 2026/02/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。