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

I am trying to create an app where user can dial a number using twilio sdk.I have installed the SDK, a

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745658120a4638665.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信