开始获取
复制一个包含安装步骤和本插件的完整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 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
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,您可以将自己的唯一ID与AppsFlyer的唯一ID和其他设备的ID进行交叉引用。 此ID可在原始数据报告和Postback API中找到,用于与内部ID进行交叉引用。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setCustomerUserId({} as AFCuid);setCurrencyCode
Section titled “设置货币代码”Sets the currency used for in-app purchases. Provide a three-character ISO 4217 code.
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setCurrencyCode({} as AFCurrency);updateServerUninstallToken
Section titled “更新卸载服务器令牌”Pass GCM/FCM tokens on Android or APNs tokens on iOS when another plugin collected them. Use this to forward uninstall measurement tokens to AppsFlyer.
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.updateServerUninstallToken({} as AFUninstall);setAppInviteOneLink
Section titled “设置应用邀请一链”Sets the OneLink ID used as the base link for invite attribution.
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setAppInviteOneLink({} as AFOnelinkID);setOneLinkCustomDomain
Section titled “设置一链自定义域”Registers branded OneLink domains so AppsFlyer can resolve attribution parameters hidden in short links.
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”当AppsFlyer 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
设置分享过滤阻止事件传播到指定的 AppsFlyer 合作伙伴。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilter({} as AFFilters);setSharingFilterForAllPartners
设置分享过滤(所有合作伙伴)阻止事件传播到所有 AppsFlyer 合作伙伴。 覆盖 setSharingFilter。
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
禁用SKAdNetworkSKAdNetwork优惠
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableSKAdNetwork({} as AFDisable);disableAdvertisingIdentifier
Section titled “disableAdvertisingIdentifier”SDK不收集广告标识符。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableAdvertisingIdentifier({} as AFDisable);disableCollectASA
Section titled “disableCollectASA”Apple Search Ads 属性设置
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
Section titled “validateAndLogInAppPurchaseIos”查看当前合同的源定义。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.validateAndLogInAppPurchaseIos({} as AFIosInAppPurchase);getSdkVersion
Section titled “getSdkVersion”获取AppsFlyer SDK版本。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.getSdkVersion();enableFacebookDeferredApplinks
Section titled “enableFacebookDeferredApplinks”启用Facebook延迟应用链接的收集。需要Facebook SDK和Facebook应用在目标/客户端设备上。 此 API必须在初始化AppsFlyer SDK之前调用,以正常工作。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.enableFacebookDeferredApplinks({} as AFFbDAL);sendPushNotificationData
Section titled “__CAPGO_KEEP_0__”推送通知数据统计和获取
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.sendPushNotificationData({} as AFPushPayload);setCurrentDeviceLanguage
Section titled “__CAPGO_KEEP_1__”设置设备语言,数据将在原始数据报告中显示
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setCurrentDeviceLanguage({} as AFLanguage);logCrossPromoteImpression
Section titled “__CAPGO_KEEP_2__”记录跨促销活动的印象。确保使用应用商店中显示的推广应用ID
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logCrossPromoteImpression({} as AFPromotion);setUserEmails
Section titled “__CAPGO_KEEP_3__”设置用户邮箱并加密
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setUserEmails({} as AFEmails);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
记录邀请用于记录用户邀请的应用内事件(af_invite)。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logInvite({} as AFLogInvite);setDisableNetworkData
Section titled “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”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
Section titled “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
Section titled “isSDKStopped”Use this method to check whether the AppsFlyer SDK is currently stopped.
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.isSDKStopped();disableAppSetId
Section titled “disableAppSetId”Disables AppSet ID collection. If called before SDK init, App Set ID will not be collected. If called after init, App Set ID will be collected but not sent in request payloads. Android only.
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);真实数据来源
Section titled “真实数据来源”本页面是由插件生成的。 src/definitions.ts当公共API上游发生变化时,重新运行同步。
如果您正在使用 开始 来规划仪表板和API操作,连接它 使用 @capgo/capacitor-appsflyer 在使用 @capgo/capacitor-appsflyer 中的原生能力 API 简介 原生能力的实现细节在 API 简介 中 介绍 原生能力的实现细节在 介绍 中 API 密钥 原生能力的实现细节在 API 密钥 中 设备 原生能力的实现细节在 设备 中