My implementation:
import RingCentral from "@rc-ex/core";
import { RingCentralCallControl } from "ringcentral-call-control";
const ringcentralSdk = new RingCentral({
server: "",
clientId: "",
clientSecret: "",
});
useEffect(() => {
if (!ringcentralSdk) {
console.error("ringcentralSdk is undefined");
return;
}
if (!webPhone) {
console.error("webPhone is undefined");
return;
}
if (ringcentralSdk && webPhone) {
const rcCall = new RingCentralCallControl({
sdk: ringcentralSdk,
});
rcCall.on("new", (newSession) => {
console.log(newSession, "rc call session");
});
// const activeSessions = rcCall.sessions;
// activeSessions.forEach((session) => {
// session.on("accepted", () => {
// console.log("Call accepted:", session);
// });
// session.on("progress", () => {
// console.log("Call in progress:", session);
// });
// session.on("established", () => {
// console.log("Call established:", session);
// });
// session.on("ringing", () => {
// toast.success("Call ringing...");
// });
// session.on("progress", () => {
// toast.success("Call in progress...");
// });
// session.on("terminated", () => {
// console.log("Call terminated:", session);
// // Handle call termination
// });
// });
// console.log(rcCall, "@@rcCall@@");
}
}, pringcentralSdk, webPhone]);
RingCentralCallControl was supposed to run after initializing ringcentralSdk. However, RingCentralCallControl throws this error Uncaught TypeError: Object prototype may only be an Object or null: undefined
at setPrototypeOf (<anonymous>)
on mounting the page without initializing