使用 @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等价物。
完整参考
- GitHub: https://github.com/Cap-go/capacitor-referrer-install/
- 文档:/docs/plugins/install-referrer/
继续使用@capgo/capacitor-install-referrer
如果您正在使用 使用@capgo/capacitor-install-referrer 为native插件工作做出计划,连接它 @capgo/capacitor-install-referrer 在@capgo/capacitor-install-referrer中了解实现细节 开始 在开始中了解实现细节 Capgo 插件目录 了解Capgo 插件目录中的产品工作流程 Capacitor 由Capgo提供的插件 了解Capacitor 由Capgo提供的插件的实现细节,并 添加或更新插件 了解添加或更新插件的实现细节