Page/area: Capgo 营销网站。 角色: 短 UI 标签或导航项。 见于: 组件 GlobalInfrastructure.astro, 页面 observe.astro。
复制一个包含安装步骤和本插件的完整 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.如果您prefer手动设置,请按照以下命令安装插件并遵循以下平台特定的说明:
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';initSDK
initSDK使用此方法初始化并启动AppsFlyer SDK。此 API 应在应用启动时立即调用。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.initSDK({ devKey: 'dev-key-123', appID: 'app-id-123',});console.log(result);startSDK
开始SDK使用此方法在手动启动模式下启动AppsFlyer SDK。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.startSDK();console.log(result);logEvent
事件日志记录应用内事件
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.logEvent({ eventName: 'event' });console.log(result);setCustomerUserId
标题:设置客户用户 ID设置客户用户 ID 可让您将自己的独特 ID 与 AppsFlyer 的独特 ID 和其他设备的 ID 进行交叉引用。 此 ID 可在原始数据报告和 Postback API 中找到,用于与内部 ID 进行交叉引用。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setCustomerUserId({ cuid: 'cuid' });setCurrencyCode
标题:设置货币代码设置用于应用内购买的货币。提供三位字符的 ISO 4217 code。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setCurrencyCode({ currencyCode: 'USD' });updateServerUninstallToken
标题:更新服务器卸载令牌将 Android 上的 GCM/FCM令牌或 iOS 上的 APNs令牌传递给另一个插件。 使用此令牌将卸载测量令牌传递给 AppsFlyer。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.updateServerUninstallToken({ token: 'token-123' });setAppInviteOneLink
标题:设置应用邀请 OneLink设置用于邀请归因的 OneLink ID 作为邀请链接的基础链接。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setAppInviteOneLink({ onelinkID: 'onelink-id-123' });setOneLinkCustomDomain
标题:设置自定义域名注册品牌化的 OneLink 域名,使 AppsFlyer 可以解析短链中的属性参数。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setOneLinkCustomDomain({ domains: ['example.com'] });appendParametersToDeepLinkingURL
标题:附加参数到深度链接 URL启用 App Links 深度链接的属性,仅需在参数映射中添加 startSDK()在参数映射中添加 pid 和 is_retargeting=true 在参数映射中添加
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.appendParametersToDeepLinkingURL({ contains: 'contains', parameters: {},});setResolveDeepLinkURLs
标题:解析深度链接 URL使用此功能,当 AppsFlyer 的 OneLink 包含在另一个 Universal Link 中时。 它让 SDK 解析包装的 URL,使深度链接仍然正常工作。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setResolveDeepLinkURLs({ urls: ['https://example.com'] });addPushNotificationDeepLinkPath
标题:添加推送通知深度链接路径配置SDK如何从推送通知包中提取深度链接值。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.addPushNotificationDeepLinkPath({ path: ['path/to/file'] });setSharingFilter
标题:设置分享过滤器阻止事件传播到指定的AppsFlyer合作伙伴。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilter({ filters: ['filter'] });setSharingFilterForAllPartners
标题:设置所有合作伙伴的分享过滤器阻止事件传播到所有AppsFlyer合作伙伴。会覆盖setSharingFilter。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilterForAllPartners();setSharingFilterForPartners
标题:设置特定合作伙伴的分享过滤器阻止事件传播到指定的AppsFlyer合作伙伴。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilterForPartners({ filters: ['filter'] });setAdditionalData
标题:设置额外数据设置用于向 AppsFlyer 发送的额外键值对数据。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setAdditionalData({ additionalData: {} });getAppsFlyerUID
标题:获取 AppsFlyer 设备 ID获取 AppsFlyer 为每个新安装的应用程序创建的唯一设备 ID。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.getAppsFlyerUID();console.log(result);anonymizeUser
标题:匿名化用户从 AppsFlyer 分析中结束用户的选项(匿名化用户数据)。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.anonymizeUser({ anonymizeUser: true });stop
标题:停止一旦调用了这个 API,我们的 SDK 就不会再与我们的服务器通信并停止运行。 在实现用户选项开启/关闭时有用。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.stop();console.log(result);disableSKAdNetwork
标题:禁用SKAdNetwork禁用SKAdNetwork
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableSKAdNetwork({ shouldDisable: true });disableAdvertisingIdentifier
标题:禁用广告标识符禁用SDK收集各种广告标识符。这包括苹果广告商标识符(IDFA)、谷歌广告标识符(GAID)、OAID和亚马逊广告标识符(AAID)。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableAdvertisingIdentifier({ shouldDisable: true });disableCollectASA
标题:禁用收集ASA禁用苹果搜索广告的归因
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableCollectASA({ shouldDisable: true });setHost
标题:设置主机设置自定义主机
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setHost({ hostPrefixName: 'host-prefix', hostName: 'host',});generateInviteLink
生成邀请链接允许您的现有用户邀请他们的朋友和联系人作为新用户加入您的应用
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.generateInviteLink({ brandDomain: 'example.com' });console.log(result);validateAndLogInAppPurchaseAndroid
验证并登录Android应用内购买API用于服务器验证应用内购买。成功验证后,会自动记录一个af_purchase事件,包含相关值。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.validateAndLogInAppPurchaseAndroid({ currency: 'USD', publicKey: 'public-key-123', signature: 'signature', purchaseData: 'purchase-data', price: 'price',});console.log(result);validateAndLogInAppPurchaseIos
验证并登录iOS应用内购买查看当前合同的源定义
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.validateAndLogInAppPurchaseIos({ currency: 'USD', inAppPurchase: 'in-app-purchase', price: 'price', transactionId: 'transaction-id-123',});console.log(result);getSdkVersion
获取AppsFlyer SDK的版本获取 AppsFlyer SDK 版本用于应用。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.getSdkVersion();console.log(result);enableFacebookDeferredApplinks
标题:“enableFacebookDeferredApplinks”启用Facebook延迟应用链接的收集。需要Facebook SDK 和目标/客户端设备上的Facebook应用。 此 API 必须在初始化AppsFlyer SDK 之前调用,以正常工作。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.enableFacebookDeferredApplinks({ enableFacebookDAL: true });console.log(result);sendPushNotificationData
标题:“sendPushNotificationData”测量和获取推送通知营销活动的数据。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.sendPushNotificationData({ pushPayload: {} });setCurrentDeviceLanguage
标题:“setCurrentDeviceLanguage”设置设备语言。数据将在原始数据报告中显示。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.setCurrentDeviceLanguage({ language: 'en-US' });console.log(result);logCrossPromoteImpression
标题:“logCrossPromoteImpression”记录作为交叉促销活动的一部分的印象。请确保使用在AppsFlyer控制台中显示的推广应用ID。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.logCrossPromoteImpression({ appID: 'app-id-123', campaign: 'campaign', parameters: {},});console.log(result);setUserEmails
标题:设置用户邮箱设置用户邮箱并加密。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.setUserEmails({ emails: ['user@example.com'] });console.log(result);logLocation
标题:日志位置手动记录用户位置
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.logLocation({ latitude: 48.8566, longitude: 2.3522,});console.log(result);setPhoneNumber
标题:设置手机号将以SHA-256加密的字符串发送。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.setPhoneNumber({ phone: '+15555550123' });console.log(result);setPartnerData
标题:设置合作伙伴数据允许发送自定义数据用于合作伙伴集成目的
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.setPartnerData({ data: {}, partnerId: 'partner-id-123',});console.log(result);logInvite
标题:logInvite用于在应用内记录用户邀请事件(af_invite)。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.logInvite({ eventParameters: {}, channel: 'channel',});console.log(result);setDisableNetworkData
标题:setDisableNetworkData用于关闭从设备中收集网络运营商名称(carrier)和SIM卡运营商名称的功能。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setDisableNetworkData({ shouldDisable: true });enableTCFDataCollection
标题:enableTCFDataCollection用于开启/关闭自动收集用户同意数据,适用于使用CMP的用户。 标志值将在应用会话之间持久化。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.enableTCFDataCollection({ shouldEnableTCFDataCollection: true });setConsentData
标题:setConsentData用于手动设置用户同意数据。 如果您的应用不使用兼容TCF v2.2的CMP,请使用以下方法手动提供同意数据直接到SDK。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setConsentData({ data: { isUserSubjectToGDPR: true } });logAdRevenue
标题:logAdRevenue通过为广告收入打上标签,应用程序所有者可以获得完整的用户LTV和广告活动ROI视图。 广告收入是通过在应用程序中显示奖励视频、推广墙、插屏广告和横幅广告来产生的。 您可以使用此方法记录广告收入。
import { AppsFlyer, MediationNetwork } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logAdRevenue({ monetizationNetwork: 'monetization-network', mediationNetwork: MediationNetwork.IRONSOURCE, currencyIso4217Code: 'USD', revenue: 1,});setConsentDataV2
标题:setConsentDataV2使用此方法手动设置用户同意数据。 如果您的应用程序不使用与TCF v2.2兼容的CMP,则使用以下方法手动向SDK提供同意数据。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setConsentDataV2({ isUserSubjectToGDPR: true, hasConsentForDataUsage: true, hasConsentForAdsPersonalization: true, hasConsentForAdStorage: true,});isSDKStarted
标题:isSDKStarted使用此方法检查是否在当前会话中已启动AppsFlyerSDK。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.isSDKStarted();console.log(result);isSDKStopped
标题:isSDKStopped使用此方法检查是否当前已停止AppsFlyerSDK。
import { AppsFlyer } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.isSDKStopped();console.log(result);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, AFPurchaseType } from '@capgo/capacitor-appsflyer';
const result = await AppsFlyer.validateAndLogInAppPurchaseV2({ purchaseDetails: { purchaseType: AFPurchaseType.oneTimePurchase, purchaseToken: 'purchase-token-123', productId: 'product-id-123', },});console.log(result);真实来源
标题:真实来源本页面由插件的 src/definitions.ts重新同步此页面时,应检查公共API是否有上游更新。
继续从Getting Started
Section titled “继续从 Getting Started”如果您正在使用 开始使用 来规划仪表板和API操作,连接它与 使用@capgo/capacitor-appsflyer 为native能力在使用@capgo/capacitor-appsflyer API概述 为API概述的实现细节 介绍 为介绍的实现细节 API密钥 为API密钥的实现细节 设备 了解设备的实现细节