跳过内容

开始

GitHub

您可以使用我们的AI辅助设置来安装插件。将以下命令添加到您的AI工具中:Capgo技能

终端窗口
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-install-referrer` plugin in my project.

如果您更喜欢手动设置,请运行以下命令安装插件并按照以下平台特定的说明:

终端窗口
bun add @capgo/capacitor-install-referrer
bunx 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 Attribution

如果您希望原生 code 调用 Apple 的 attribution 端点,请传递 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 在为有效令牌准备 attribution 数据时, attribution 数据仍在准备中。重试选项控制原生插件在拒绝之前重试的频率。请参阅 iOS attribution 查看平台详细信息。

兼容性别名

兼容性别名

GetReferrer() 兼容性别名 cap-play-install-referrer.

const result = await InstallReferrer.GetReferrer();

New code should use getReferrer().

继续从 Getting Started

标题:继续从 Getting Started

如果您正在使用 Getting Started 来规划原生插件工作,连接它与 使用 @capgo/capacitor-install-referrer 在使用 @capgo/capacitor-install-referrer 中的原生能力 Capgo 插件目录 在 Capgo 插件目录 中的产品工作流 Capacitor 由 Capgo 的插件 在 Capacitor 由 Capgo 的插件 中的实现细节 添加或更新插件 为添加或更新插件的实现细节 Ionic Enterprise 插件替代方案 为 Ionic Enterprise 插件替代方案的产品工作流