I am trying to subscribe to a ring-central event via @sdk/subscriptions.
useEffect(() => {
if (!subscriptions || !selectedAccountId || !selectedCompanyId) return;
const subscription = subscriptions.createSubscription();
subscription.on(subscription.events.notification, handleTelephonySessionNotification);
subscription
.setEventFilters(["/restapi/v1.0/account/~/extension/~/telephony/sessions"])
.register()
.then((subscription) => {
setTelephonySessionsSubscription(subscription);
})
.catch((err) => console.error("Failed to register to telephony session notifications", err));
return () => {
telephonySessionsSubscription?.revoke();
};
}, [subscriptions, selectedAccountId, selectedCompanyId]);
However, I get the following error due to .register():
RingCentralSoftphone.tsx:265 Failed to register to telephony session notifications TypeError: Cannot read properties of undefined (reading 'addEventListener')
When I click the source of the error, this is where I end up:
setupWsEventListener() {
this.wse.ws.addEventListener("message", this.eventListener);
}
I am using React + Typescript + Vite. I have installed nodePolyfills for the ring central sdk to even work.
I found no mention of such an issue anywhere on the Internet.
I am trying to subscribe to a ring-central event via @sdk/subscriptions.
However, I get the following error due to .register():
When I click the source of the error, this is where I end up:
I am using React + Typescript + Vite. I have installed nodePolyfills for the ring central sdk to even work.
I found no mention of such an issue anywhere on the Internet.