跳过内容

开始使用

安装

安装
终端窗口
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';

API概述

API概述

使用此方法初始化并启动AppsFlyer SDK。此 API 应尽快在应用启动时调用。

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

startSDK

开始SDK

仅在手动启动模式下使用此方法启动 AppsFlyer SDK。

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

logEvent

日志事件

在应用中记录事件。

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

setCustomerUserId

设置客户ID

设置客户ID使您可以将自己的唯一ID与AppsFlyer的唯一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);
设置邀请 OneLink

设置邀请 OneLink ID,用于邀请属性的基础链接。

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

setOneLinkCustomDomain

设置 OneLink 自定义域

为 AppsFlyer 注册自定义 OneLink 域名,以便解析短链中的属性参数。

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

appendParametersToDeepLinkingURL

向 App Links 深度链接 URL 追加属性

在不使用 OneLink 的情况下启用 App Links 深度链接的属性。请在调用此方法之前 startSDK()复制到剪贴板 pid 和在参数映射中。 is_retargeting=true 复制到剪贴板

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

Use this when an AppsFlyer OneLink is wrapped inside another Universal Link. It lets the SDK resolve the wrapped URL so deep linking still works correctly.

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

Configures how the SDK extracts deep link values from push notification payloads.

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

复制到剪贴板

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

getAppsFlyerUID

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

disableSKAdNetwork

“禁用SKAdNetwork”

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

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版本

获取应用Flyer SDK 版本

import { AppsFlyer } from '@capgo/capacitor-appsflyer';
await AppsFlyer.getSdkVersion();
Facebook延迟应用链接的收集

启用Facebook延迟应用链接的收集。需要Facebook SDK 和 Facebook 应用程序在目标/客户端设备上。 此 API 必须在初始化 AppsFlyer 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

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

设置手机号

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

setDisableNetworkData

设置禁用网络数据

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

logAdRevenue

记录广告收入

通过为广告收入进行归因,应用程序所有者可以获得完整的用户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);

检测是否已启动 AppsFlyer SDK

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

API 服务器端验证内购 V2。 如果验证成功,则会自动记录 af_purchase 事件并包含相关值。

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

本页是根据插件生成的 src/definitions.ts当公共API上游发生变化时,请重新同步。