聊天- 反应- 本地化- 窗口
- 支持的 Chatwoot 版本 : 2.1.6.0+ (单位:千美元)
安装
使用纱线或 npm 这样安装库 :
yarn add @chatwoot/react-native-widget
或
npm install --save @chatwoot/react-native-widget
这个库取决于 反应-本地-网络视图 财务报告和审定财务报表 同步存储请遵照文件中的指示.
iOS 安装
如果使用回放原生版本 > 60.0,则相对直截了当.
cd ios && pod install
如何使用
- 通过遵循此处描述的步骤在聊天室服务器中创建一个网站频道 https://www.chatwoot.com/docs/channels/website (中文(简体) )
- 替换
websiteToken螺旋桨和baseUrl
import React, { useState } from 'react';
import { StyleSheet, View, SafeAreaView, TouchableOpacity, Text } from 'react-native';
import ChatWootWidget from '@chatwoot/react-native-widget';
const App = () => {
const [showWidget, toggleWidget] = useState(false);
const user = {
identifier: '[email protected]',
name: 'John Samuel',
avatar_url: '',
email: '[email protected]',
identifier_hash: '',
};
const customAttributes = { accountId: 1, pricingPlan: 'paid', status: 'active' };
const websiteToken = 'WEBSITE_TOKEN';
const baseUrl = 'CHATWOOT_INSTALLATION_URL';
const locale = 'en';
const colorScheme='dark'
return (
<SafeAreaView style={styles.container}>
<View>
<TouchableOpacity style={styles.button} onPress={() => toggleWidget(true)}>
<Text style={styles.buttonText}>Open widget</Text>
</TouchableOpacity>
</View>
{
showWidget&&
<ChatWootWidget
websiteToken={websiteToken}
locale={locale}
baseUrl={baseUrl}
closeModal={() => toggleWidget(false)}
isModalVisible={showWidget}
user={user}
customAttributes={customAttributes}
colorScheme={colorScheme}
/>
}
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
button: {
height: 48,
marginTop: 32,
paddingTop: 8,
paddingBottom: 8,
backgroundColor: '#1F93FF',
borderRadius: 8,
borderWidth: 1,
borderColor: '#fff',
justifyContent: 'center',
},
buttonText: {
color: '#fff',
textAlign: 'center',
paddingLeft: 10,
fontWeight: '600',
fontSize: 16,
paddingRight: 10,
},
});
export default App;
结束了!
整个例子在 /example 文件夹.
道具
| 名称 | 默认 | 类型 | 说明 |
|---|---|---|---|
| 基数Url | - 说吧 | 字符串 | Chatwoot 安装 URL |
| 网站Token | - 说吧 | 字符串 | 网站频道代号 |
| 颜色方案 | 光线 | 字符串 | 部件颜色方案( 浅/ 暗/ 自动) |
| 语言 | 内 | 字符串 | 语言 |
| 是 Modal 可视性 | 虚假 | 布尔 | 部件是否可见 |
| 关闭 Modal | - 说吧 | 函数 | 闭幕活动 |
| 用户 | {} | 对象 | 用户信息, 如电子邮件、 用户名和 avatar url |
| 自定义属性 | {} | 对象 | 关于客户的补充资料 |
反馈贡献( A)
如果你有什么想谈的 请随意加入我们 解析器 说话!
欢呼 2017-2023 Chatwoot Inc-根据麻省理工学院许可证发布.