Dify 向移动端的用户交付方案
· 阅读需 2 分钟
开源方案
为人工智能开发者提供移动端输出方案
// 创建开发 token
client.devToken('john')
// 建立消息渠道
const channel = client.channel('messaging', 'the_park', {
name: 'The Park',
});
- 消息列表
import React, { useState } from 'react';
import { Channel as ChannelType, StreamChat } from 'stream-chat';
import { ChannelList, Chat, OverlayProvider } from 'stream-chat-react-native';
const client = StreamChat.getInstance('api_key');
export const App = () => {
const [channel, setChannel] = useState<ChannelType>();
return (
<OverlayProvider>
<Chat client={client}>
{channel ? <Channel channel={channel}>{/** App components */}</Channel> : <ChannelList onSelect={setChannel} />}
</Chat>
</OverlayProvider>
);
};
- 导航设置
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { Chat, OverlayProvider } from 'stream-chat-react-native';
const client = StreamChat.getInstance('api_key');
const Stack = createStackNavigator<{ home: undefined }>();
export const App = () =>
<NavigationContainer>
<OverlayProvider>
<Chat client={client}>
<Stack.Navigator>
<Stack.Screen component={() => {/** App components */})} name='home' />
</Stack.Navigator>
</Chat>
</OverlayProvider>
</NavigationContainer>;
- medium -》 文章翻译 -》 国内平台(公众号、头条)