首页 > 解决方案 > Twilio 聊天包导致应用程序在 reactjs 中使用错误的令牌崩溃

问题描述

我正在验证 Twilio 凭据,然后再将它们保存到 db。所以在前端 reactjs 我从后端获得一个令牌,我需要通过 twilio-chat 客户端。因此,如果这成功,我将显示 twilio 聊天凭据很好,但如果我更改 apiKey,我会得到错误的令牌,所以当我将此令牌传递给 twilio-chat 客户端时。它在一段时间后使应用程序崩溃。

import Client from "twilio-chat";

Client.create(data?.testUserAccessToken)
          .then((client) => {
            if (client) {
              notify.notification({
                type: "success",
                message: "Successfully Tested"                                                                                                                                                                      
              });
          })
          .catch((error) => {
            // console.log(error);
            notify.notification({
              type: "warning",
              message: "Invalid Credentials."
            });
          });

我正在使用 twilio-chat 4.0.0 版。

在此处输入图像描述

你们能帮我解决我在这里缺少的或做错的事情吗?这对我很有帮助。谢谢

标签: reactjstwiliotwilio-programmable-chat

解决方案


推荐阅读