# @extole/react-native-sdk 中文文档

规范地址：https://npmcn.com/package/%40extole/react-native-sdk/

版本：1\.0\.34
npm 元数据更新时间：2026-11-13T09:41:20.782Z
中文译文更新时间：2026-11-14T06:00:04.107Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40extole/react-native-sdk
原文对照：https://npmcn.com/package/%40extole/react-native-sdk/?lang=original
项目主页：https://github.com/extole/react-native-sdk#readme
源码仓库：https://github.com/extole/react-native-sdk

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：279 kB，174 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：react \*，react-native \*，react-native-webview \*，@react-navigation/stack \*，@react-navigation/native \*，@react-navigation/native-stack \*，react-native-safe-area-context \*
- 首次发布：2022-11-15T14:02:27.907Z
- 最新版本发布：2026-11-13T09:41:20.538Z
- 近 30 天下载量：4566（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：34（近 12 个月 8 个）

## 中文简介

Extole 反应原生 SDK

## 安装

```sh
npm install @extole/react-native-sdk
```

也可以使用：`pnpm add @extole/react-native-sdk`、`yarn add @extole/react-native-sdk`、`bun add @extole/react-native-sdk`

## README

# Extole 反应原生 SDK

这个集成指南向您演示了如何与我们的Resact Industrial SDK一起尽快建立并启动一个Extole程序.

## 所需资源

Extole React Introduct SDK支持iOS 13.0或后期,而Android支持minSdkVersion 21或后期.

## 安装 SDK 依赖

添加数据 `extole-mobile-sdk` 依赖性 :

```
npm install @extole/react-native-sdk react-native-webview
```

在iOS上,将Extole iOS SDK添加到应用程序中 `Podfile`在应用目标内部 CocoaPods干线没有SDK所需的版本,因此出自GitHub:

```ruby
pod 'ExtoleMobileSDK', :git => 'https://github.com/extole/ios-sdk.git', :tag => '0.0.103'
pod 'ExtoleConsumerAPI', :git => 'https://github.com/extole/ios-consumer-api.git', :tag => '0.0.24'
```

然后,在 `ios` 目录, 运行 `pod install`。一个已经拥有这些被子的应用程序 `Podfile.lock` 运行 `pod update ExtoleMobileSDK ExtoleConsumerAPI extole-mobile-sdk` 换句话说.

## 初始化 SDK

初始化 extole :

```
import {Extole} from '@extole/extole-mobile-sdk';


const extole = new Extole('share.client.com');
```

您需要提供您的 Extole 程序域以取代 `'share.client.com'`。 。 。 .

## 初始化视图

在代码中,通过配置 `view` 和回调 :

```
const [extoleView, setExtoleView] = React.useState<React.ReactNode>(<View />);

extole.configure(extoleView, setExtoleView, () => {
    navigation.navigate('Promo');
});

// Use the extole.view
function ExtoleScreen(): ReactElement {
  return return extole.view as ReactElement;
}

// The ExtoleScreen() method is used as a Screen
<Stack.Screen name='Promo' component={ExtoleScreen} />

```

默认情况下,Extole会使用这个单一视图与客户互动.

## 与 extole 交换数据

### 客户信息

发送关于客户的删除信息 :

```
extole.identify("<email@domain.tld>", {"partner_user_id": "123"})
```

您可以选择通过任何类型的数据来描述客户. 关于你的客户的更丰富的数据 给了你的营销团队 他们需要的信息 更好地划分你的程序参与者 并以适当的运动瞄准他们.

### 活动

发送删除事件, 如注册、 签名、 转换、 账户打开等 :

```
extole.sendEvent("cta_viewed", {"key": "value"}))
```

对于每个事件类型,可以发送额外数据. 例如,在转换事件上,您可能想要通过,以排列ID或顺序值等.

### 行动呼吁内容

使用 Extole 的内容发布一个行动呼吁( CTA) .

移动菜单项目等CTA可以在"我的Extole Campaign"编辑器中完全定制. 每个CTA都有指定区. 以下代码是通过取取区内容来取回CTA的例子:

```
const [zone, setZone] = React.useState<Zone | null>(null);
React.useEffect(() => {
    extole
      .fetchZone('mobile_cta')
      .then(([zone, _campaign]) => {
        setZone(zone);
      });
}, []);

// On CTA tap send the event to Extole
const onShareButtonPress = () => {
  extole.sendEvent(cta?.touch_event, { extole_zone_name: 'microsite' });
};

. . . 

// Usage example:
<View style={styles.container}>
  <Image
    style={styles.tinyLogo}
    source={{
      uri: zone?.getData().image || '<default image link>',
    }}
  />
  <View style={styles.space} />
  <Button title={zone?.getData().title || ''} onPress={onShareButtonPress} />
  <View style={styles.space} />
</View>
```

## 为了能够取回 `cta` 区域,该区域应在 My Extole 中配置,并应返回包含 `image` 财务报告和审定财务报表 `title`。 。 。 .

重要注意:我们鼓励您从My Extole中调取 CTA 内容, 因为这样做可以确保您的菜单项目或上覆信件会反映副本, 并提供您为竞选所配置的.

# 高级使用

以下话题涵盖Extole React Independent SDK的高级使用案例. 如果你们想探讨其中任何一种选择,请联系我们的支助小组 [支持@extole.com](mailto:support@extole.com)。 。 。 .

## 从事件中配置动作

您可以设置一个特定动作, 当一个事件被发射时发生 。 例如,当客户在您的菜单项目CTA上点击时,您可能会希望事件触发一个动作来加载您的微站并显示共享体验.

要设置这种类型的配置, 您需要与 Extole 支持合作, 在 My Extole 中设置一个带条件和行动返回 JSON 配置的区域 。 SDK 对特定事件通过的条件执行动作 :

```
{
  "operations": [
    {
      "conditions": [
        {
          "type": "EVENT",
          "event_names": [
            "cta_tap"
          ]
        }
      ],
      "actions": [
        {
          "type": "VIEW_FULLSCREEN",
          "zone_name": "microsite"
        }
      ]
    }
  ]
}
```

### 支持的行动

以下类型的动作在我们的SDK中默认支持.

<table><tbody><tr><td><strong>动作名称</strong></td><td><strong>说明</strong></td></tr><tr><td><code>PROMPT</code></td><td>显示 iOS 的弹出通知 。 例如,当折扣码或优惠券码被成功应用时,就可能出现这种情况.</td></tr><tr><td><code>NATIVE_SHARING</code></td><td>以客户可以通过短信或任何已启用的社会应用程序发送的预定义消息和链接打开本地共享表.</td></tr><tr><td><code>VIEW_FULLSCREEN</code></td><td>触发全屏移动网络视图 。 例如,这可能是您在 My Extole 中配置的用于显示共享体验的微站点 .</td></tr></tbody></table>

### 自定义动作

如果您想要创建超出默认的自定义动作, 请使用以下示例中显示的格式 。 请联系支援小组 [支持@extole.com](mailto:support@extole.com) 如果你有任何问题.

#### 实例自定义动作

```
export class CustomReactAction implements Action {
  type = 'CUSTOM';
  title = 'REACT_ACTION';

  execute(_event: AppEvent, _extole: Extole) {
    console.log('Custom Action was executed', this);
  }
}
```

#### 注册自定义动作

```
extole.registerAction('CUSTOM', CustomReactAction.prototype);
```

## 附 录

### 高级动作

#### 装入操作

装入额外操作

```
{
  "type": "LOAD_OPERATIONS",
  "zones": [
    "<zone_name>"
  ],
  "data": {
    "key": "value"
  }
}
```

#### 获取

获取和缓存内容

```
{
  "type": "FETCH",
  "zones": [
    "<zone_name_1>",
    "<zone_name_2>"
  ]
}
```

#### 设置日志级别

用于配置日志级别(DEBUG、INFO、WARN、ERROR)

```
{
  "type": "SET_LOG_LEVEL",
  "log_level": "WARN"
}
```

## 常见问题

### @extole/react-native-sdk 是什么？

Extole 反应原生 SDK

### 如何安装 @extole/react-native-sdk？

在项目目录运行 npm install @extole/react-native-sdk，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（\*）、react-native（\*）、react-native-webview（\*）、@react-navigation/stack（\*）、@react-navigation/native（\*）、@react-navigation/native-stack（\*）、react-native-safe-area-context（\*）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @extole/react-native-sdk 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @extole/react-native-sdk 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @extole/react-native-sdk 可以商用吗？

@extole/react-native-sdk 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @extole/react-native-sdk 的下载量有多少？

根据 npm 官方下载统计，@extole/react-native-sdk 在 2026/10/14 – 2026/11/12 这 30 天内被下载 4,566 次，日均约 152 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @extole/react-native-sdk 还在维护吗？

最新版本 1\.0\.34 发布于 2026/11/13（今天）；至今共发布 34 个版本，其中过去 12 个月发布了 8 个；首次发布于 2022/11/15。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

