开始获取
复制一个包含安装步骤和本插件的完整 Markdown 指南的配置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-appsflyer`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/appsflyer/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
安装
安装bun add @capgo/capacitor-appsflyerbunx cap sync导入
导入import { AppsFlyer } from '@capgo/capacitor-appsflyer';import type { AFAdRevenueData, AFAndroidInAppPurchase, AFAnonymizeUser, AFAppendToDeepLink, AFConsentData, AFConsentOptions, AFCuid, AFCurrency, AFData, AFDisable, AFEmails, AFEnableTCFDataCollection, AFEvent, AFFbDAL, AFFilters, AFHost, AFInit, AFIosInAppPurchase, AFLanguage, AFLatLng, AFLinkGenerator, AFLogInvite, AFOnelinkDomain, AFOnelinkID, AFPartnerData, AFPath, AFPhone, AFPromotion, AFPurchaseDetailsV2, AFPushPayload, AFUninstall, AFUrls,} from '@capgo/capacitor-appsflyer';API概述
API概述initSDK
initSDK使用此方法初始化并启动AppsFlyer SDK。此 API 应该在应用程序启动时立即调用。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.initSDK({} as AFInit);startSDK
开始SDK仅在手动启动模式下使用此方法启动 AppsFlyer SDK。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.startSDK();logEvent
日志事件在应用中记录事件。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logEvent({} as AFEvent);setCustomerUserId
设置客户ID设置客户ID使您可以将自己的唯一ID与AppsFlyer的唯一ID和其他设备的ID进行交叉引用。 此ID可在原始数据报告和Postback API中找到,用于与内部ID进行交叉引用。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setCustomerUserId({} as AFCuid);setCurrencyCode
设置货币代码设置应用内购买的货币。提供三位字符的ISO 4217 code。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setCurrencyCode({} as AFCurrency);updateServerUninstallToken
Section titled “updateServerUninstallToken”在 Android 上传递 GCM/FCM 代币,或在 iOS 上传递 APNs 代币,另一个插件收集它们。 将卸载测量代币传递给 AppsFlyer。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.updateServerUninstallToken({} as AFUninstall);setAppInviteOneLink
Section titled “setAppInviteOneLink”设置用于邀请归因的 OneLink ID 作为邀请链接的基本链接。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setAppInviteOneLink({} as AFOnelinkID);setOneLinkCustomDomain
Section titled “setOneLinkCustomDomain”注册自定义 OneLink 域名,以便 AppsFlyer 可以解析短链中的归因参数。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setOneLinkCustomDomain({} as AFOnelinkDomain);appendParametersToDeepLinkingURL
Section titled “appendParametersToDeepLinkingURL”在 App Links 深度链接中启用归因,未使用 OneLink 的情况下。请在此方法之前调用。
至少包含 startSDK()复制到剪贴板 pid and is_retargeting=true 在参数映射中。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.appendParametersToDeepLinkingURL({} as AFAppendToDeepLink);setResolveDeepLinkURLs
标题:设置深度链接URLs当应用Flyer OneLink 包含在另一个 Universal Link 内时使用。 它让 SDK 解析包裹的URL,因此深度链接仍然正常工作。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setResolveDeepLinkURLs({} as AFUrls);addPushNotificationDeepLinkPath
标题:添加推送通知深度链接路径配置 SDK 从推送通知包裹中提取深度链接值的方式。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.addPushNotificationDeepLinkPath({} as AFPath);setSharingFilter
标题:设置共享过滤器阻止事件传播到指定的应用Flyer 合作伙伴。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilter({} as AFFilters);setSharingFilterForAllPartners
Section titled “setSharingFilterForAllPartners”阻止所有 AppsFlyer 合作伙伴接收事件。 覆盖 setSharingFilter。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilterForAllPartners();setSharingFilterForPartners
Section titled “setSharingFilterForPartners”阻止特定 AppsFlyer 合作伙伴接收事件。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilterForPartners({} as AFFilters);setAdditionalData
Section titled “setAdditionalData”设置额外的键值对数据发送到 AppsFlyer。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setAdditionalData({} as AFData);getAppsFlyerUID
Section titled “getAppsFlyerUID”获取 AppsFlyer 的唯一设备 ID(每个新安装的应用程序都会创建一个)。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.getAppsFlyerUID();anonymizeUser
Section titled “匿名化用户”End User Opt-Out from AppsFlyer analytics (匿名化用户数据).
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.anonymizeUser({} as AFAnonymizeUser);一旦调用了这个 API,我们的 SDK 就不会再与我们的服务器通信并停止运行。 在实现用户自愿或不自愿时有用。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.stop();disableSKAdNetwork
Section titled “禁用SKAdNetwork”禁用 SKAdNetwork
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableSKAdNetwork({} as AFDisable);disableAdvertisingIdentifier
Section titled “禁用广告标识符”禁用 SDK 收集各种广告 ID。这包括苹果广告商标识符 (IDFA)、谷歌广告 ID (GAID)、OAID 和亚马逊广告 ID (AAID)。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableAdvertisingIdentifier({} as AFDisable);disableCollectASA
Section titled “disableCollectASA”退出苹果搜索广告的贡献。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableCollectASA({} as AFDisable);setHost
Section titled “setHost”设置自定义主机。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setHost({} as AFHost);generateInviteLink
Section titled “generateInviteLink”允许您的现有用户邀请他们的朋友和联系人作为新用户加入您的应用。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.generateInviteLink({} as AFLinkGenerator);validateAndLogInAppPurchaseAndroid
Section titled “validateAndLogInAppPurchaseAndroid”API用于服务器验证应用内购买。 如果验证成功,会自动记录一个af_purchase事件,包含相关值。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.validateAndLogInAppPurchaseAndroid({} as AFAndroidInAppPurchase);validateAndLogInAppPurchaseIos
验证并登录iOS应用查看当前合同的源定义。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.validateAndLogInAppPurchaseIos({} as AFIosInAppPurchase);getSdkVersion
获取SDK版本获取应用Flyer SDK 版本
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.getSdkVersion();enableFacebookDeferredApplinks
Facebook延迟应用链接的收集启用Facebook延迟应用链接的收集。需要Facebook SDK 和目标/客户端设备上的Facebook应用。 此 API 必须在初始化应用Flyer SDK 之前调用,以正常工作。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.enableFacebookDeferredApplinks({} as AFFbDAL);sendPushNotificationData
推送通知数据测量从推送通知活动中获取数据。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.sendPushNotificationData({} as AFPushPayload);setCurrentDeviceLanguage
setCurrentDeviceLanguage设置设备语言。数据将在原始数据报告中显示
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setCurrentDeviceLanguage({} as AFLanguage);logCrossPromoteImpression
logCrossPromoteImpression在跨促销活动中记录一次 impression。确保使用 AppsFlyer 控制台中显示的推广应用 ID
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logCrossPromoteImpression({} as AFPromotion);setUserEmails
setUserEmails设置用户电子邮件并加密
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setUserEmails({} as AFEmails);logLocation
logLocation手动记录用户位置
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logLocation({} as AFLatLng);setPhoneNumber
设置手机号将以SHA-256加密的字符串形式发送。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setPhoneNumber({} as AFPhone);setPartnerData
设置合作伙伴数据用于合作伙伴集成目的发送自定义数据。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setPartnerData({} as AFPartnerData);logInvite
记录邀请用户在-app事件(af_invite)复制到剪贴板
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logInvite({} as AFLogInvite);setDisableNetworkData
用于关闭从设备中收集网络运营商名称(运营商)和SIM卡运营商名称的功能。复制到剪贴板
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setDisableNetworkData({} as AFDisable);enableTCFDataCollection
Section titled “enableTCFDataCollection”用于启用/禁用自动收集用户同意数据,适用于使用CMP的用户。 标志值将在应用程序会话之间持久化。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.enableTCFDataCollection({} as AFEnableTCFDataCollection);setConsentData
Section titled “setConsentData”使用此方法手动设置用户同意数据。 如果您的应用程序不使用与TCF v2.2兼容的CMP,请使用以下方法手动提供同意数据直接到SDK。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setConsentData({} as AFConsentData);logAdRevenue
Section titled “logAdRevenue”通过为广告收入进行归因,应用程序所有者可以获得完整的用户LTV和营销活动ROI视图。 广告收入是通过在应用程序中显示奖励视频、推广墙、插屏广告和横幅广告来产生的。 您可以使用此方法记录您的广告收入。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logAdRevenue({} as AFAdRevenueData);setConsentDataV2
Section titled “setConsentDataV2”使用此方法手动设置用户同意数据。 如果您的应用程序不使用与TCF v2.2兼容的CMP,请使用以下方法手动提供同意数据直接到SDK。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setConsentDataV2({} as AFConsentOptions);isSDKStarted
Section titled “isSDKStarted”使用此方法检查当前会话中是否已经启动了 AppsFlyer SDK。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.isSDKStarted();isSDKStopped
Section titled “isSDKStopped”使用此方法检查 AppsFlyer SDK 是否当前处于停止状态。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.isSDKStopped();disableAppSetId
Section titled “disableAppSetId”禁用 AppSet ID 收集。若在 SDK 初始化之前调用,则 App Set ID 不会被收集。若在初始化之后调用,则 App Set ID 会被收集但不会在请求包中发送。仅限 Android。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableAppSetId();validateAndLogInAppPurchaseV2
Section titled “validateAndLogInAppPurchaseV2”API 服务器端验证应用内购买 V2。 如果验证成功,则会自动记录 af_purchase 事件及其相关值。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.validateAndLogInAppPurchaseV2({} as AFPurchaseDetailsV2);数据源
数据源本页面由插件生成 src/definitions.ts当公共API发生更改时,请重新同步
继续从开始
继续从开始如果您正在使用 开始 规划仪表板和API操作,请将其连接到 使用@capgo/capacitor-appsflyer 在使用@capgo/capacitor-appsflyer时,native能力 API概述 为实现细节在 API 概述中 简介 为实现细节在简介中 API 密钥 为实现细节在 API 密钥中,以及 设备 为实现细节在设备中。