开始使用
复制一个设置提示,包含安装步骤和该插件的完整 Markdown 指南。
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.
安装
终端窗口bun add @capgo/capacitor-install-referrerbunx cap syncCopy a setup prompt with the install steps and the full markdown guide for this plugin.
Section titled “Import”import { InstallReferrer } from '@capgo/capacitor-install-referrer';查看认证细节
Section titled “查看认证细节”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);}Fetch Apple Attribution On iOS
Section titled “Fetch Apple Attribution On iOS”如果您希望本地 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 在为有效令牌准备认证数据时,认证数据仍在准备中。重试选项控制本地插件在拒绝之前多久重试。请参阅 iOS 认证 平台详细信息。
兼容性别名
兼容性别名GetReferrer() 可用于从 cap-play-install-referrer.
const result = await InstallReferrer.GetReferrer();新code应使用 getReferrer().