跳过内容

开始

终端窗口
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 属性

如果您希望本地 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();

New code should use getReferrer().

继续从 Getting Started

继续从 Getting Started

如果您正在使用 Getting Started 来规划原生插件工作,连接它与 使用 @capgo/capacitor-install-referrer for the native capability in Using @capgo/capacitor-install-referrer, Capgo 插件目录 产品工作流程在Capgo插件目录中 Capacitor插件由Capgo提供 产品工作流程在Capacitor插件由Capgo提供 添加或更新插件 添加或更新插件的实现细节 Ionic企业插件替代方案 产品工作流程在Ionic企业插件替代方案中