跳过主要内容
返回插件
@capgo/capacitor-install-referrer
教程
由 github.com/Cap-go 提供

安装referrer

从Capacitor读取Google Play安装referrer数据和Apple AdServices attribution

指南

安装referrer的教程

使用@capgo/capacitor-install-referrer

@capgo/capacitor-install-referrer 读取安装来源信号在Capacitor应用中。

在需要通过一个API获取Android的Google Play安装引荐数据和iOS的Apple AdServices安装令牌时使用它。

安装

bun add @capgo/capacitor-install-referrer
bunx cap sync

此插件暴露的内容

  • getReferrer 返回Android或iOS的安装来源详细信息。
  • GetReferrer 是从 cap-play-install-referrer.
  • Android返回Play引荐字符串、点击时间戳、安装时间戳和即时应用标志。
  • iOS返回一个AdServices安装令牌,并可选地获取Apple的安装来源载荷。

示例使用

import { InstallReferrer } from '@capgo/capacitor-install-referrer';

const result = await InstallReferrer.getReferrer();

if (result.platform === 'android') {
  console.log(result.referrer);
}

if (result.platform === 'ios') {
  console.log(result.attributionToken);
}

Apple安装来源载荷

const result = await InstallReferrer.getReferrer({
  fetchAppleAttribution: true,
  appleAttributionRetryCount: 3,
  appleAttributionRetryDelayMs: 5000,
});

console.log(result.appleAttribution);

平台说明

Android使用Google Play安装引荐服务,并需要Play商店安装才能获取真实的引荐数据。iOS使用Apple AdServices,因为Apple没有提供一个通用的App Store安装引荐等价物。

全参考