快速入门
复制包含安装步骤和该插件完整 Markdown 指南的配置 prompt。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-install-referrer`
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/install-referrer/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 skills 添加到你的 AI 工具中:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下 prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-install-referrer` plugin in my project.如果你更想手动设置,请运行以下命令安装插件,并按照下方各平台的说明操作:
bun add @capgo/capacitor-install-referrerbunx cap sync导入
“导入”章节import { InstallReferrer } from '@capgo/capacitor-install-referrer';查看归因详情
“查看归因详情”章节const result = await InstallReferrer.getReferrer();
if (result.platform === 'android') { console.log('Install referrer:', result.referrer); console.log('Click timestamp:', result.clickTimestampSeconds); console.log('Install timestamp:', result.installBeginTimestampSeconds);}
if (result.platform === 'ios') { console.log('AdServices token:', result.attributionToken);}在 iOS 上获取 Apple 归因数据
“在 iOS 上获取 Apple 归因”章节如果你希望原生 code 调用 Apple 的归因端点,请传入 fetchAppleAttribution.
const result = await InstallReferrer.getReferrer({ fetchAppleAttribution: true, appleAttributionRetryCount: 3, appleAttributionRetryDelayMs: 5000,});
// result.appleAttribution is the parsed Apple attribution response.// See the iOS attribution page for the Apple-provided payload fields.console.log(result.appleAttribution);Apple 可能返回 404 而有效 token 的归因数据仍在准备中。重试选项控制原生插件在拒绝前的重试频率。详情请参阅 iOS 归因 了解各平台细节。
GetReferrer() is available for apps migrating from cap-play-install-referrer.
const result = await InstallReferrer.GetReferrer();新的 code 应使用 getReferrer().
从入门指南继续
“从入门指南继续”章节如果你正在使用 快速入门 要规划原生插件工作,请将其与 使用 @capgo/capacitor-install-referrer 以使用 @capgo/capacitor-install-referrer 中的原生能力, Capgo 插件目录 查看 Capgo 插件目录中的产品工作流, Capgo 提供的 Capacitor 插件 查看由 Capgo 提供的 Capacitor 插件中的实现细节, 添加或更新插件 关于“添加或更新插件”中的实现细节,以及 Ionic Enterprise 插件替代方案 关于“Ionic Enterprise 插件替代方案”中的产品工作流。