开始使用
复制一个设置提示,包括安装步骤和此插件的完整 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 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 介绍
Section titled “API 介绍”initSDK
Section titled “initSDK”使用此方法初始化并启动 AppsFlyer SDK。此 API 应在应用程序启动时立即调用。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.initSDK({} as AFInit);startSDK
Section titled “startSDK”使用此方法在手动启动模式下启动 AppsFlyer SDK。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.startSDK();logEvent
Section titled “logEvent”记录应用内事件。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logEvent({} as AFEvent);setCustomerUserId
标题:设置客户用户 ID设置客户用户 ID 可以让您在 AppsFlyer 的唯一 ID 和其他设备的 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
标题:更新服务器卸载令牌将 Android 上的 GCM/FCM令牌或 iOS 上的 APNs令牌传递给另一个插件。 使用此令牌将卸载测量令牌传递给 AppsFlyer。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.updateServerUninstallToken({} as AFUninstall);setAppInviteOneLink
标题:设置应用邀请 OneLink设置用于邀请归因的 OneLink ID 作为邀请链接的基础链接。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setAppInviteOneLink({} as AFOnelinkID);setOneLinkCustomDomain
标题:设置自定义域注册品牌 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合作伙伴。 覆盖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
标题:禁用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
标题:"enableFacebookDeferredApplinks"启用Facebook延迟应用链路的收集。需要Facebook SDK和目标/客户端设备上的Facebook应用。 此API必须在初始化AppsFlyerSDK之前调用,以便正常工作。
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
标题:设置用户电子邮件设置用户电子邮件并加密它们。
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
标题:logInvite用于在应用程序内记录用户邀请事件(af_invite)。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logInvite({} as AFLogInvite);setDisableNetworkData
标题:setDisableNetworkData用于在设备上禁用收集网络运营商名称(运营商)和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使用此方法手动设置用户同意数据。 如果您的应用程序不使用与TCF v2.2兼容的CMP,请使用以下方法手动向SDK提供同意数据。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setConsentDataV2({} as AFConsentOptions);isSDKStarted
标题:isSDKStarted使用此方法检查是否在当前会话中已启动AppsFlyerSDK。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.isSDKStarted();isSDKStopped
标题:isSDKStopped使用此方法检查AppsFlyerSDK是否当前处于停止状态。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.isSDKStopped();disableAppSetId
标题:禁用AppSet ID禁用AppSet ID的收集。如果在SDK初始化之前调用,App Set ID不会被收集。 如果在初始化之后调用,App Set ID会被收集,但不会在请求负载中发送。 仅限Android。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableAppSetId();validateAndLogInAppPurchaseV2
标题:验证和登录应用程序购买V2API用于服务器验证应用程序购买V2。 如果验证成功,会自动记录一个af_purchase事件,包含相关值。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.validateAndLogInAppPurchaseV2({} as AFPurchaseDetailsV2);真实来源
标题:真实来源本页面是由插件生成的。 src/definitions.ts当公共API上游更改时,请重新运行同步。