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.
您可以使用我们的AI辅助设置来安装插件。使用以下命令将Capgo技能添加到您的AI工具中:
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 syncimport { 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
标题:startSDK使用此方法在手动启动模式下启动 AppsFlyer SDK。
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 可以让您在 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 传递给另一个插件收集的 token。 使用此功能将卸载测量令牌传递给 AppsFlyer。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.updateServerUninstallToken({} as AFUninstall);setAppInviteOneLink
标题为“setAppInviteOneLink”设置用于邀请归因的 OneLink ID 作为基础链接。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setAppInviteOneLink({} as AFOnelinkID);setOneLinkCustomDomain
标题为“setOneLinkCustomDomain”注册带有 OneLink 域名的 OneLink 域名,以便 AppsFlyer 可以解析在短链中隐藏的属性参数。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setOneLinkCustomDomain({} as AFOnelinkDomain);appendParametersToDeepLinkingURL
标题为“appendParametersToDeepLinkingURL”启用 App Links 深度链接的属性,仅在没有 OneLink 时使用。请在调用此方法之前 startSDK()。
包含至少 pid 和 is_retargeting=true 在参数映射中。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.appendParametersToDeepLinkingURL({} as AFAppendToDeepLink);setResolveDeepLinkURLs
标题为“setResolveDeepLinkURLs”在 OneLink 包装在另一个 Universal Link 内时使用。 它让 SDK 解析包装的 URL,因此深度链接仍然正常工作。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setResolveDeepLinkURLs({} as AFUrls);addPushNotificationDeepLinkPath
标题为“addPushNotificationDeepLinkPath”配置了SDK从推送通知包中提取深度链接值的方式。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.addPushNotificationDeepLinkPath({} as AFPath);setSharingFilter
标题为“setSharingFilter”阻止事件传播到指定的AppsFlyer合作伙伴。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilter({} as AFFilters);setSharingFilterForAllPartners
标题为“setSharingFilterForAllPartners”阻止事件传播到所有AppsFlyer合作伙伴。覆盖了setSharingFilter。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilterForAllPartners();setSharingFilterForPartners
标题为“setSharingFilterForPartners”阻止事件传播到指定的AppsFlyer合作伙伴。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilterForPartners({} as AFFilters);setAdditionalData
标题为“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 分析中的 Opt-Out(匿名化用户数据)。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.anonymizeUser({} as AFAnonymizeUser);stop
标题:停止一旦调用了这个 API,我们的 SDK 就不会再与我们的服务器通信并停止运行。 在实施用户 Opt-in/Opt-out 时有用。
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 收集各种广告 ID。包括苹果广告商标识符 (IDFA)、谷歌广告 ID (GAID)、OAID 和亚马逊广告 ID (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版本获取AppsFlyer SDK版本
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.getSdkVersion();enableFacebookDeferredApplinks
标题:启用Facebook延迟应用链接Enable the collection of Facebook Deferred AppLinks. Requires Facebook SDK and Facebook app on target/client device. This API must be invoked before initializing the AppsFlyer SDK in order to function properly.
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.enableFacebookDeferredApplinks({} as AFFbDAL);sendPushNotificationData
标题:“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”记录作为交叉促销活动的一部分的印象。确保使用在 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
标题:setPartnerData用于伙伴整合目的的自定义数据发送。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setPartnerData({} as AFPartnerData);logInvite
标题:logInvite用来记录用户邀请内应用事件(af_invite)。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logInvite({} as AFLogInvite);setDisableNetworkData
标题:"setDisableNetworkData"用来关闭收集网络运营商名称(carrier)和SIM卡运营商名称的功能。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setDisableNetworkData({} as AFDisable);enableTCFDataCollection
标题:"enableTCFDataCollection"用来开启/关闭自动收集用户同意数据,适用于使用CMP的用户。 标志值将在应用程序会话之间持久化。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.enableTCFDataCollection({} as AFEnableTCFDataCollection);setConsentData
标题:"setConsentData"用来手动设置用户同意数据。 如果您的应用程序不使用与TCF v2.2兼容的CMP,使用以下方法手动提供同意数据直接给SDK。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setConsentData({} as AFConsentData);logAdRevenue
标题:"logAdRevenue"通过将广告收入归因于应用程序所有者,可以获得完整的用户LTV和广告活动ROI视图。 广告收入是通过在应用程序中显示视频广告、推广墙、插屏广告和横幅广告来产生的。 您可以使用此方法记录广告收入。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logAdRevenue({} as AFAdRevenueData);setConsentDataV2
标题为“setConsentDataV2”Use this to set user consent data manually. If your app doesn’t use a CMP compatible with TCF v2.2, use the following method to manually provide the consent data directly to the SDK.
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setConsentDataV2({} as AFConsentOptions);isSDKStarted
标题为“isSDKStarted”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”Use this method to check whether the AppsFlyer SDK is currently stopped.
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 继续如果您正在使用 开始使用 为了规划仪表板和API操作,连接它 使用@capgo/capacitor-appsflyer 在使用@capgo/capacitor-appsflyer中, API概述 在API概述中了解实现细节 介绍 在介绍中了解实现细节 API密钥 在API密钥中了解实现细节 设备 在设备中了解实现细节