开始
复制安装提示并包含该插件的完整Markdown指南。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-app-tracking-transparency`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/app-tracking-transparency/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
您可以使用我们的AI辅助设置来安装插件。使用以下命令将Capgo技能添加到您的AI工具中:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下提示:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-app-tracking-transparency` plugin in my project.如果您更喜欢手动设置,请按照以下命令安装插件并遵循以下平台特定的说明:
bun add @capgo/capacitor-app-tracking-transparencybunx cap sync导入
标题为“导入”import { AppTrackingTransparency } from '@capgo/capacitor-app-tracking-transparency';API概述
标题为“API概述”getStatus
标题为“getStatus”获取当前跟踪授权状态,用户不会被提示。
import { AppTrackingTransparency } from '@capgo/capacitor-app-tracking-transparency';
const { status } = await AppTrackingTransparency.getStatus();if (status === 'authorized') { console.log('Tracking is authorized');}requestPermission
请求权限请求用户授权以访问跟踪相关的应用数据。 显示原生iOS跟踪权限对话框。
注意:此方法只会显示对话框一次。随后的调用 将返回存储的授权状态而不显示对话框。
import { AppTrackingTransparency } from '@capgo/capacitor-app-tracking-transparency';
const { status } = await AppTrackingTransparency.requestPermission();switch (status) { case 'authorized': console.log('User authorized tracking'); break; case 'denied': console.log('User denied tracking'); break; case 'restricted': console.log('Tracking is restricted'); break; case 'notDetermined': console.log('Status not determined'); break;}类型参考
跟踪状态AppTrackingStatusResponse
响应对象,包含跟踪授权状态。复制到剪贴板
export interface AppTrackingStatusResponse { /** * The current tracking authorization status. * * @since 1.0.0 */ status: AppTrackingStatus;}AppTrackingStatus
requestPermission跟踪授权状态的可能值。
export type AppTrackingStatus = 'authorized' | 'denied' | 'notDetermined' | 'restricted';真实来源
标题为“真实来源”的部分本页由插件生成。重新同步公共__CAPGO_KEEP_0__时,重新运行同步。 src/definitions.ts. Re-run the sync when the public API changes upstream.
标题为“继续从Getting Started”的部分
如果您正在使用Getting Started 来规划仪表板和__CAPGO_KEEP_0__操作,请将其连接到 使用@API/__CAPGO_KEEP_1__-app-tracking-transparency Using @capgo/capacitor-app-tracking-transparency 为使用 @capgo/capacitor-app-tracking-transparency 原生功能 API概述 为API概述中的实现细节 简介 为简介中的实现细节 API密钥 为API密钥中的实现细节, 和 设备 为设备中的实现细节