反应原生 AEP 核心扩展
@adobe/react-native-acpcore iOS、tvOS和Android周围的包装器 AEP 核心SDK 允许与 React Industrial 应用程序融合。 启用Core扩展的功能完全通过下面所记录的JavaScript提供.
目录
所需资源
@adobe/react-native-acpcore 1.x需求React Native 0.44.+@adobe/react-native-acpcore 2.x需求React Native 0.60.+
安装
你需要安装 SDK 与 无 并配置本地的Android/iOS项目.
注意:如果你是新来的,我们建议你遵循 启动原生状态 继续前页.
1. 创建反应土著项目
首先创建 React 本地项目 :
react-native init MyReactApp
注:随行 反应原生 tvos 支持 用 tvos 目标创建应用程序.
2. 安装 JavaScript 软件包
安装和链接 @adobe/react-native-acpcore 软件包 :
cd MyReactApp
npm install @adobe/react-native-acpcore
2.1 链接
- 反应原生0.60+
CLI 自动链接功能 在构建应用程序时链接模块.
- 原生反应 0.59
react-native link @adobe/react-native-acpcore
注:如果使用Cocoapods,则运行:
cd ios/ && pod install
3. 配置本地项目
3.1 iOS项目
(仅需 原生反应 0.59(中文(简体) )
在Link Binary With Library部分中,单击+链接并添加以下框架和库:
UIKit.frameworkSystemConfiguration.frameworkWebKit.frameworkUserNotifications.frameworklibsqlite3.0.tbdlibc++.tbdlibz.tbd
4. 今后的步骤
在您安装了 Core后,您可以安装额外的 AEP React 原生扩展.
| 延长 | npm 软件包 |
|---|---|
| 分析 | |
| 观众 | |
| 运动 | |
| 媒体 | |
| 目标 | |
| 用户配置 |
测试
这个项目包含在《公约》第2条(a)项中包含的笑话单元测试 __tests__ 目录,用于在本地运行测试 :
make run-tests-locally
使用量
初始化 :
初始化 SDK 应在本地代码中完成, 有关如何初始化 SDK 的文件可以找到 这里。链接的文档初始化了不需要的用户配置扩展名,但是,如果您对用户配置扩展名有兴趣,可以找到它 这里。 。 。 .
一旦您在应用程序中添加了初始化代码, 请在启动 SDK 之前将 SDK 包装器类型设置为 React Native .
iOS: (英语)
[ACPCore setWrapperType:ACPMobileWrapperTypeReactNative];
机器人:
MobileCore.setWrapperType(WrapperType.REACT_NATIVE);
核心
更新 SDK 配置 :
ACPCore.updateConfiguration({"yourConfigKey": "yourConfigValue"});
获取 SDK 版本 :
ACPCore.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPCore version: " + version));
获取日志级别 :
ACPCore.getLogLevel().then(level => console.log("AdobeExperienceSDK: Log Level = " + level));
控制 SDK 的日志级别 :
import {ACPMobileLogLevel} from '@adobe/react-native-acpcore';
ACPCore.setLogLevel(ACPMobileLogLevel.VERBOSE);
使用 AEP 日志 API :
import {ACPMobileLogLevel} from '@adobe/react-native-acpcore';
ACPCore.log(ACPMobileLogLevel.ERROR, "React Native Tag", "React Native Message");
说明: ACPMobileLogLevel 包含以下获取器 :
const ERROR = "ACP_LOG_LEVEL_ERROR";
const WARNING = "ACP_LOG_LEVEL_WARNING";
const DEBUG = "ACP_LOG_LEVEL_DEBUG";
const VERBOSE = "ACP_LOG_LEVEL_VERBOSE";
获取当前隐私状态 :
ACPCore.getPrivacyStatus().then(status => console.log("AdobeExperienceSDK: Privacy Status = " + status));
设置隐私状态 :
import {ACPMobilePrivacyStatus} from '@adobe/react-native-acpcore';
ACPCore.setPrivacyStatus(ACPMobilePrivacyStatus.OPT_IN);
说明: ACPMobilePrivacyStatus 包含以下获取器 :
const OPT_IN = "ACP_PRIVACY_STATUS_OPT_IN";
const OPT_OUT = "ACP_PRIVACY_STATUS_OPT_OUT";
const UNKNOWN = "ACP_PRIVACY_STATUS_UNKNOWN";
获取 SDK 身份 :
ACPCore.getSdkIdentities().then(identities => console.log("AdobeExperienceSDK: Identities = " + identities));
调度活动中心活动:
import {ACPExtensionEvent} from '@adobe/react-native-acpcore';
var event = new ACPExtensionEvent("eventName", "eventType", "eventSource", {"testDataKey": "testDataValue"});
ACPCore.dispatchEvent(event);
以召回方式发出事件中心活动:
import {ACPExtensionEvent} from '@adobe/react-native-acpcore';
var event = new ACPExtensionEvent("eventName", "eventType", "eventSource", {"testDataKey": "testDataValue"});
ACPCore.dispatchEventWithResponseCallback(event).then(responseEvent => console.log("AdobeExperienceSDK: responseEvent = " + responseEvent));
发出事件中心响应活动:
import {ACPExtensionEvent} from '@adobe/react-native-acpcore';
var responseEvent = new ACPExtensionEvent("responseEvent", "eventType", "eventSource", {"testDataKey": "testDataValue"});
var requestEvent = new ACPExtensionEvent("requestEvent", "eventType", "eventSource", {"testDataKey": "testDataValue"});
ACPCore.dispatchResponseEvent(responseEvent, requestEvent);
身份
获取扩展版本 :
ACPIdentity.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPIdentity version: " + version));
同步标识符 :
ACPIdentity.syncIdentifier("identifierType", "identifier", ACPMobileVisitorAuthenticationState.AUTHENTICATED);
同步标识符 :
ACPIdentity.syncIdentifiers({"id1": "identifier1"});
与认证状态同步标识符 :
import {ACPMobileVisitorAuthenticationState} from '@adobe/react-native-acpcore';
ACPIdentity.syncIdentifiersWithAuthState({"id1": "identifier1"}, ACPMobileVisitorAuthenticationState.UNKNOWN);
说明: ACPMobileVisitorAuthenticationState 包含以下获取器 :
const AUTHENTICATED = "ACP_VISITOR_AUTH_STATE_AUTHENTICATED";
const LOGGED_OUT = "ACP_VISITOR_AUTH_STATE_LOGGED_OUT";
const UNKNOWN = "ACP_VISITOR_AUTH_STATE_UNKNOWN";
设置广告标识符 :
ACPCore.setAdvertisingIdentifier("adID");
将访问者数据添加到 URL :
ACPIdentity.appendVisitorInfoForURL("test.com").then(urlWithVisitorData => console.log("AdobeExperienceSDK: VisitorData = " + urlWithVisitorData));
获取访问者数据为 URL 查询参数字符串 :
ACPIdentity.getUrlVariables().then(urlVariables => console.log("AdobeExperienceSDK: UrlVariables = " + urlVariables));
获取标识符 :
ACPIdentity.getIdentifiers().then(identifiers => console.log("AdobeExperienceSDK: Identifiers = " + identifiers));
获取经验云ID:
ACPIdentity.getExperienceCloudId().then(cloudId => console.log("AdobeExperienceSDK: CloudID = " + cloudId));
设置驱动标识符 :
ACPCore.setPushIdentifier("pushIdentifier");
访问类 :
import {ACPVisitorID} from '@adobe/react-native-acpcore';
var visitorId = new ACPVisitorID(idOrigin?: string, idType: string, id?: string, authenticationState?: ACPMobileVisitorAuthenticationState)
生命周期
注:通过Javascript实施生命周期可能导致生命周期计量不准确,因此我们建议在本地实施生命周期 Android 和 iOS 代码。 。 。 .
获取扩展版本 :
ACPLifecycle.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPLifecycle version: " + version));
信号
获取扩展版本 :
ACPSignal.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPSignal version: " + version));
收集PII:
ACPCore.collectPii({"myPii": "data"});
解决问题
- 不运行可能造成一些不同的错误
react-native link @adobe/react-native-acpcore或当 React Introduct 0.60.x 中的自动链接器在构建时没有正确链接 SDK 时.
-
TypeError: null is not an object (evaluating RCTACPCore...) -
ACPCore.h导入时未找到<RCTACPCore/ACPCore.h> -
在 Javascript 中执行后, 没有 SDK 日志或出错
react-native link @adobe/react-native-acpcore
cd ios/ && pod install # only if using pods
另一个可能的问题是,您的应用程序是使用 Expo不幸的是 Expo 不支持框外的本地模块。 请看 退出到 ExpoKit 中。 。 。 .
Specs satisfying the RCTACPCore (from ../node_modules/@adobe/react-native-acpcore) dependency were found, but they required a higher minimum deployment target.
- AEP SDK要求至少iOS 10.0正常运行. 如果您看到此错误, 请确保
Podfile物种至少为iOS 10.0.
捐款
见 捐款
许可证
见 自由主义