最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - React js With Vite not able to setup device on twilio voice - Stack Overflow

programmeradmin10浏览0评论

I am trying to create an app where user can dial a number using twilio sdk. I have installed the SDK, and then have set up the device using the token.

The device is getting initiazed. BUt it should ideally go into device.on event. Unfortunately that is not happening.

I have tried the token and the implementation using vaniall Javascript, and that implementation is working perfectly fine.

this is my code

import { Device } from "@twilio/voice-sdk";


try {
      const newDevice = new Device(token, {
        codecPreferences: ["opus", "pcmu"],
        fakeLocalDTMF: true,
        debug: "all", // Increase logging verbosity
      });
      console.log("here--->77", newDevice);
      newDevice.on("ready", () => {
        console.log("here--->78");
        setIsReady(true);
        setStatus("Ready");
      });
      newDevice.on("connect", () => setStatus("Connected"));
      newDevice.on("disconnect", () => {
        console.log("here--->83");
        setStatus("Disconnected");
      });
      newDevice.on("error", (err) => {
        console.log(err);
        setError(err.message);
      });
      newDevice.on("ringing", () => {
        console.error("ringing");
        setStatus("Ringing");
      });
      newDevice.on("reject", () => {
        console.error("Call was rejected");
        setStatus("Rejected");
      });
      setDevice(newDevice);
} catch (err) {
      console.error("Error initializing device:", err);
      setError("Failed to initialize Twilio device");
}

In the console, I can see here--->77 But then the execution stops. I dont get anything. Not even an error.

发布评论

评论列表(0)

  1. 暂无评论