跳过内容

Getting Started

GitHub

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-appsflyer
bunx 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';

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();

在应用中记录事件。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logEvent({} as AFEvent);

设置自己的客户 ID 可以将自己的唯一 ID 与 AppsFlyer 的唯一 ID 和其他设备的 ID 进行交叉引用。 此 ID 在原始数据报告和 Postback API 中可用,用于与内部 ID 进行交叉引用。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setCustomerUserId({} as AFCuid);

设置应用内购买的货币。提供一个三位字符的 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);

设置用于邀请归因的 OneLink ID 作为基础链接。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setAppInviteOneLink({} as AFOnelinkID);

注册品牌 OneLink 域名,以便 AppsFlyer 可以解析短链中的归因参数。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setOneLinkCustomDomain({} as AFOnelinkDomain);

appendParametersToDeepLinkingURL

标题:附加参数到深度链接 URL

启用 App Links 深度链接归因,无需 OneLink。请在调用此方法之前 startSDK()至少包含 pidis_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);

阻止事件传播到指定的应用内链(AppsFlyer)合作伙伴。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilter({} as AFFilters);

阻止事件传播到所有应用内链(AppsFlyer)合作伙伴。会覆盖设置的分享过滤器。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilterForAllPartners();

阻止事件传播到指定的AppsFlyer合作伙伴。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setSharingFilterForPartners({} as AFFilters);

设置要发送给AppsFlyer的额外键值数据。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setAdditionalData({} as AFData);

获取AppsFlyer为每个新安装的应用程序创建的唯一设备ID。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.getAppsFlyerUID();

AppsFlyer分析的用户隐私保护(匿名化用户数据)。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.anonymizeUser({} as AFAnonymizeUser);

一旦调用了这个API,我们的SDK就不再与我们的服务器通信,停止运行。 在实现用户自愿/自愿退出时有用。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.stop();

退出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);

退出苹果搜索广告的归因

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableCollectASA({} as AFDisable);

设置自定义主机。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setHost({} as AFHost);
标题:生成邀请链接

允许您的现有用户邀请他们的朋友和联系人作为新用户加入您的应用

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);

获取应用飞行器 SDK 版本

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.getSdkVersion();
标题:启用 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);

记录跨促销活动中的曝光。确保使用在 AppsFlyer 控制台中显示的推广应用 ID。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logCrossPromoteImpression({} as AFPromotion);

设置用户电子邮件并加密。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setUserEmails({} as AFEmails);

手动记录用户位置

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logLocation({} as AFLatLng);

将以 SHA-256 加密的字符串发送。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setPhoneNumber({} as AFPhone);

用于合作伙伴整合目的发送自定义数据。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setPartnerData({} as AFPartnerData);

用于记录用户邀请的应用内事件(af_invite)。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logInvite({} as AFLogInvite);

用于禁用从设备中收集网络运营商名称(运营商)和 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);

手动设置用户同意数据。 如果您的应用程序不使用与 TCF v2.2 兼容的 CMP,则使用以下方法手动向 SDK 提供同意数据。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setConsentData({} as AFConsentData);

通过为广告收入进行归因,应用程序所有者可以获得用户 LTV 和广告活动 ROI 的完整视图。 广告收入是通过在应用程序中显示奖励视频、推广墙、插屏广告和横幅广告来产生的。 您可以使用此方法记录广告收入。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.logAdRevenue({} as AFAdRevenueData);

手动设置用户同意数据。 如果您的应用程序不使用与 TCF v2.2 兼容的 CMP,则使用以下方法手动向 SDK 提供同意数据。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.setConsentDataV2({} as AFConsentOptions);

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();

使用此方法检查是否当前禁用了AppsFlyer SDK。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.isSDKStopped();

禁用AppSet ID收集。如果在 SDK 初始化之前调用,App Set ID将不会被收集。 如果在初始化后调用,App Set ID将被收集但不会在请求包中发送。 仅限Android。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.disableAppSetId();

validateAndLogInAppPurchaseV2

标题:validateAndLogInAppPurchaseV2

API用于服务器验证V2的应用内购买。 如果验证成功,会自动记录一个af_purchase事件,包含相关值。

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.validateAndLogInAppPurchaseV2({} as AFPurchaseDetailsV2);

本页面由插件生成 src/definitions.ts. 当上游的公共 API 变更时,请重新同步

如果您正在使用 Getting Started 来规划仪表板和 API 操作,请将其连接到 使用 @capgo/capacitor-appsflyer 为在使用 @capgo/capacitor-appsflyer 中的原生功能 API Overview 为在 API Overview 中的实现细节 介绍 在介绍中实现细节 API 键 在 API 键中实现细节, 设备 在设备中实现细节。