Getting Started
复制一个包含安装步骤和完整 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.
安装
标题为“安装”You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下提示:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-appsflyer` plugin in my project.如果您更喜欢手动设置,请按照以下命令安装插件并遵循以下平台特定的说明:
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 Overview
Section titled “API Overview”Use this method to initialize and start AppsFlyer SDK. This API should be called as soon as the app launches.
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.initSDK({} as AFInit);Use this method to start AppsFlyer SDK, only on manual start mode.
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.startSDK();logEvent
标题:logEvent在应用中记录事件。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logEvent({} as AFEvent);setCustomerUserId
标题:setCustomerUserId设置自己的客户 ID 可以将自己的唯一 ID 与 AppsFlyer 的唯一 ID 和其他设备的 ID 进行交叉引用。 此 ID 在原始数据报告和 Postback API 中可用,用于与内部 ID 进行交叉引用。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setCustomerUserId({} as AFCuid);setCurrencyCode
标题:setCurrencyCode设置应用内购买的货币。提供一个三位字符的 ISO 4217 code。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setCurrencyCode({} as AFCurrency);updateServerUninstallToken
标题:updateServerUninstallToken在 Android 上传递 GCM/FCM token 或在 iOS 上传递 APNs token,另一个插件收集它们。 使用此功能将卸载测量令牌传递给 AppsFlyer。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.updateServerUninstallToken({} as AFUninstall);setAppInviteOneLink
标题:设置应用邀请链接设置用于邀请归因的 OneLink ID 作为基础链接。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setAppInviteOneLink({} as AFOnelinkID);setOneLinkCustomDomain
标题:设置 OneLink 自定义域注册品牌 OneLink 域名,以便 AppsFlyer 可以解析短链中的归因参数。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setOneLinkCustomDomain({} as AFOnelinkDomain);appendParametersToDeepLinkingURL
标题:附加参数到深度链接 URL启用 App Links 深度链接归因,无需 OneLink。请在调用此方法之前 startSDK()至少包含 pid 和 is_retargeting=true 在参数映射中
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.appendParametersToDeepLinkingURL({} as AFAppendToDeepLink);setResolveDeepLinkURLs
标题:设置深度链接URL当应用内链(AppsFlyer 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
标题:设置分享过滤器阻止事件传播到指定的应用内链(AppsFlyer)合作伙伴。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilter({} as AFFilters);setSharingFilterForAllPartners
标题:设置所有合作伙伴的分享过滤器阻止事件传播到所有应用内链(AppsFlyer)合作伙伴。会覆盖设置的分享过滤器。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilterForAllPartners();setSharingFilterForPartners
标题:设置合作伙伴共享过滤器阻止事件传播到指定的AppsFlyer合作伙伴。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilterForPartners({} as AFFilters);setAdditionalData
标题:设置额外数据设置要发送给AppsFlyer的额外键值数据。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setAdditionalData({} as AFData);getAppsFlyerUID
标题:获取AppsFlyer的设备ID获取AppsFlyer为每个新安装的应用程序创建的唯一设备ID。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.getAppsFlyerUID();anonymizeUser
标题:匿名化用户AppsFlyer分析的用户隐私保护(匿名化用户数据)。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.anonymizeUser({} as AFAnonymizeUser);stop
标题:“停止”一旦调用了这个API,我们的SDK就不再与我们的服务器通信,停止运行。 在实现用户自愿/自愿退出时有用。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.stop();disableSKAdNetwork
标题:“禁用SKAdNetwork”退出SKAdNetwork
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableSKAdNetwork({} as AFDisable);disableAdvertisingIdentifier
标题:“禁用广告标识符”禁用SDK收集各种广告标识符。这包括苹果广告商身份(IDFA)、谷歌广告标识符(GAID)、OAID和亚马逊广告标识符(AAID)。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableAdvertisingIdentifier({} as AFDisable);disableCollectASA
标题:“禁用收集ASA”退出苹果搜索广告的归因
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableCollectASA({} as AFDisable);setHost
标题:设置主机设置自定义主机。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setHost({} as AFHost);generateInviteLink
标题:生成邀请链接允许您的现有用户邀请他们的朋友和联系人作为新用户加入您的应用
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.generateInviteLink({} as AFLinkGenerator);validateAndLogInAppPurchaseAndroid
标题:验证并登录Android应用内购买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 版本获取应用飞行器 SDK 版本
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.getSdkVersion();enableFacebookDeferredApplinks
标题:启用 Facebook 延迟应用链接启用 Facebook 延迟应用链接的收集。需要 Facebook SDK 和 Facebook 应用程序在目标/客户端设备上。 此 API 必须在初始化应用飞行器 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
标题:设置设备语言设置设备语言。数据将在原始数据报告中显示
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setCurrentDeviceLanguage({} as AFLanguage);logCrossPromoteImpression
标题:《logCrossPromoteImpression》记录跨促销活动中的曝光。确保使用在 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
标题:《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
标题:记录邀请用于记录用户邀请的应用内事件(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
标题:启用 TCF 数据收集用于启用/禁用自动收集用户使用 CMP 的同意数据。 标志值将在应用程序会话之间持久化。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.enableTCFDataCollection({} as AFEnableTCFDataCollection);setConsentData
标题:设置用户同意数据手动设置用户同意数据。 如果您的应用程序不使用与 TCF v2.2 兼容的 CMP,则使用以下方法手动向 SDK 提供同意数据。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setConsentData({} as AFConsentData);logAdRevenue
标题:记录广告收入通过为广告收入进行归因,应用程序所有者可以获得用户 LTV 和广告活动 ROI 的完整视图。 广告收入是通过在应用程序中显示奖励视频、推广墙、插屏广告和横幅广告来产生的。 您可以使用此方法记录广告收入。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logAdRevenue({} as AFAdRevenueData);setConsentDataV2
标题:设置用户同意数据 v2手动设置用户同意数据。 如果您的应用程序不使用与 TCF v2.2 兼容的 CMP,则使用以下方法手动向 SDK 提供同意数据。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setConsentDataV2({} as AFConsentOptions);isSDKStarted
标题:检查 SDK 是否启动Use this method to check whether the AppsFlyer SDK has already been started in the current session.
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.isSDKStarted();isSDKStopped
标题:isSDKStopped使用此方法检查是否当前禁用了AppsFlyer SDK。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.isSDKStopped();disableAppSetId
标题:disableAppSetId禁用AppSet ID收集。如果在 SDK 初始化之前调用,App Set ID将不会被收集。 如果在初始化后调用,App Set ID将被收集但不会在请求包中发送。 仅限Android。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableAppSetId();validateAndLogInAppPurchaseV2
标题:validateAndLogInAppPurchaseV2API用于服务器验证V2的应用内购买。 如果验证成功,会自动记录一个af_purchase事件,包含相关值。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.validateAndLogInAppPurchaseV2({} as AFPurchaseDetailsV2);真实来源
标题:真实来源本页面由插件生成 src/definitions.ts. 当上游的公共 API 变更时,请重新同步
从 Getting Started 继续
标题为“从 Getting Started 继续”如果您正在使用 Getting Started 来规划仪表板和 API 操作,请将其连接到 使用 @capgo/capacitor-appsflyer 为在使用 @capgo/capacitor-appsflyer 中的原生功能 API Overview 为在 API Overview 中的实现细节 介绍 在介绍中实现细节 API 键 在 API 键中实现细节, 设备 在设备中实现细节。