问题描述
当前,我已将此chatbot嵌入到WebView
这样的东西中。
import React,{ useRef } from 'react';
import { StyleSheet,View,SafeAreaView } from 'react-native';
import HeaderV2 from '../../components/HeaderV2';
import { WebView,WebViewNavigation } from 'react-native-webview';
export default function LandBotPage() {
const botUrl = 'BOT_URL_HERE';
const webViewRef = useRef<WebView>();
return (
<SafeAreaView style={styles.container}>
<HeaderV2 />
<View style={styles.container}>
<WebView
ref={webViewRef}
originWhitelist={['*']}
startInLoadingState={false}
cacheEnabled={false}
pullToRefreshEnabled={true}
style={styles.webView}
source={{ uri: botUrl }}
onNavigationStateChange={(navstate: WebViewNavigation) => {
console.log(navstate.url);
}}
/>
</View>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {flex: 1 },webView: {flex: 1 },});
解决方法
我不确定您可以通过什么方式实现此特定的聊天机器人,我查看了Landbot网站,但找不到开发人员文档。
我能给您的一个普遍答案是,您可以使用increase()
和<View>
实现所需的外观,然后通过<Text>
调用来调用Chatbot API端点。您可以在官方文档here中阅读有关在React Native应用程序中获取数据的更多信息。