1

我已将网络聊天插入 webview 以在 android 应用程序中显示机器人,我希望用户将用相机拍摄的照片发送给机器人。

问题是附加文件的默认按钮打开资源管理器而不是相机,所以我实现了一个按钮来启动相机,现在我需要以编程方式将拍摄的图片发送给机器人。

我已经设法使用我自己的网络聊天商店版本向机器人发送文本:

store = window.WebChat.createStore();
window.WebChat.renderWebChat({
directLine: window.WebChat.createDirectLine({ token: json.token }),
store
}, document.getElementById('webchat'));
document.querySelector('#cameraButton').addEventListener('click', async () => {
    store.dispatch({
        type: 'WEB_CHAT/SEND_MESSAGE',
        payload: { text: "some text" }
    });
});

有没有办法做到这一点?

[编辑] 我在WebChat 的代码中看到了类似的文件,但我不确定它是否可以使用以及如何使用:

const SEND_FILES = 'WEB_CHAT/SEND_FILES';

export default function sendFiles(files) {
  return {
    type: SEND_FILES,
    payload: { files }
  };
}

export { SEND_FILES };
4

0 回答 0