跳过主要内容

安装referrer Capacitor插件

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

安装

bun add @capgo/capacitor-install-referrer bunx cap sync
npm、pnpm或yarn
  • npm install @capgo/capacitor-install-referrer
  • pnpm add @capgo/capacitor-install-referrer
  • yarn add @capgo/capacitor-install-referrer

指南

如何在 Capacitor 中使用 Install Referrer

在设备上测试

下载 Capgo 应用,然后扫描二维码 code

安装引荐插件预览二维码 code

使用 @capgo/capacitor-install-referrer

@capgo/capacitor-install-referrer 读取 Capacitor 应用中的安装 attribution 信号。

当您需要在 Android 和 Apple AdServices 上通过一个 API 获取 Google Play 安装引荐数据和 iOS 的 attribution 代币时,请使用它。

安装

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

此插件暴露的内容

  • getReferrer 返回 Android 或 iOS 的安装 attribution 详情。
  • GetReferrer 这是一个过时的兼容性别名,用于从 cap-play-install-referrer.
  • Android 返回 Play 引荐字符串、点击时间戳、安装时间戳和即时应用标志。
  • iOS会返回一个AdServices attribution令牌,并可选地从Apple获取attribution负载。

示例用法

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 Attribution负载

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

console.log(result.appleAttribution);

平台说明

Android使用Google Play Install Referrer服务,并需要在Play Store中安装应用程序以获取真实的referrer数据。iOS使用Apple AdServices,因为Apple没有提供一个通用的App Store安装referrer等价物。

完整参考

继续使用@capgo/capacitor-install-referrer

如果您正在使用 使用@capgo/capacitor-install-referrer 为native插件工作做出计划,连接它 @capgo/capacitor-install-referrer 在@capgo/capacitor-install-referrer中了解实现细节 开始 在开始中了解实现细节 Capgo 插件目录 了解Capgo 插件目录中的产品工作流程 Capacitor 由Capgo提供的插件 了解Capacitor 由Capgo提供的插件的实现细节,并 添加或更新插件 了解添加或更新插件的实现细节

常见问题

安装referrer插件FAQ

如何在Capacitor应用中安装安装referrer插件?

Run "bun add @capgo/capacitor-install-referrer" (or "npm install @capgo/capacitor-install-referrer"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-install-referrer" in your app code.

是否支持 @capgo/capacitor-install-referrer 与 React、Vue 和 Angular 一起使用?

是。 Install Referrer 是一个 Capacitor 包,因此它与任何运行在 Capacitor 内的 Web 框架一起工作,包括 Ionic、React、Vue、Angular、Svelte 和普通 JavaScript。

哪个 Capacitor 版本支持 @capgo/capacitor-install-referrer?

Capgo 插件遵循 Capacitor 的主要版本:使用与您的 Capacitor 主要版本匹配的插件主要版本(例如插件 v8 与 Capacitor 8)。 在 GitHub README 中的兼容性表格中列出了维护的版本。

是否支持 @capgo/capacitor-install-referrer 免费和开源?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-install-referrer/ and the package is free to install from npm. Bug reports and pull requests are welcome.

是否可以在不经过 App Store 审核的情况下更新使用 Install Referrer 的 code?

安装或升级插件会更改原生 code,因此需要一个新的商店构建。 之后,JavaScript、HTML 和 CSS 的更改可以立即与 Capgo 的实时更新一起发布。

无需等待应用程序审查即可将安装引荐者更改推送给用户

一旦插件在您的商店构建中,Capgo即刻将您的JavaScript、HTML和CSS更改推送给用户

开始使用Capgo