Yeastar-PBX / ys-webrtc-sdk-ui

0 stars 1 forks source link

Uncaught TypeError: Cannot read properties of undefined (reading 'init') #1

Closed CovertError closed 6 months ago

CovertError commented 6 months ago

I'm not sure if this works with you but this what i did

`` because i use vite so im doing this on my app.js

import YSWebRTC from "ys-webrtc-sdk-ui"; window.YSWebRTC = YSWebRTC;

let me know if I'm missing something

SNH-48 commented 6 months ago

If you are using import YSWebRTC from "ys-webrtc-sdk-ui" , you can directly utilize the YSWebRTC module without the need to reassign it to window.YSWebRTC.。 npm install ys-webrtc-sdk-ui first.

import { init } from 'ys-webrtc-sdk-ui';
const container = document.getElementById('container');
// Initialization
init(container, {
    username: '1000',
    secret: 'sdkshajgllliiaggskjhf',
    pbxURL: 'https://192.168.1.1:8088'
}).then(data => {
// Obtain the exposed instances for additional business needs
const { phone, pbx, destroy, on } = data;
    // ...
}).catch(err=>{
    console.log(err)
})

BTW make sure your init config is correct,The account configuration in the sample code is not available。 @CovertError

CovertError commented 6 months ago

I tried doing this replacing the information with our information and what i get is this and I'm using google chrome my project is running on TALL Stack and I'm using vite for asset https://vitejs.dev/ please let me know if there is something I'm missing

ys-webrtc-sdk-ui.js?v=a4c45421:24605 Uncaught Error: Automatic publicPath is not supported in this browser
    at ys-webrtc-sdk-ui.js?v=a4c45421:24605:19
    at ys-webrtc-sdk-ui.js?v=a4c45421:24607:10
    at ys-webrtc-sdk-ui.js?v=a4c45421:24608:8
    at ys-webrtc-sdk-ui.js?v=a4c45421:9:82
    at node_modules/ys-webrtc-sdk-ui/lib/ys-webrtc-sdk-ui.js (ys-webrtc-sdk-ui.js?v=a4c45421:10:6)
    at __require (chunk-34KZWS7D.js?v=a4c45421:5:50)
    at ys-webrtc-sdk-ui.js?v=a4c45421:24612:16
import { init } from 'ys-webrtc-sdk-ui';
const container = document.getElementById('container');
// Initialization
init(container, {
    username: '1000',
    secret: 'sdkshajgllliiaggskjhf',
    pbxURL: 'https://192.168.1.1:8088'
}).then(data => {
    const { phone, pbx, destroy, on } = data;
    console.log(data);
}).catch(err=>{
    console.log(err)
});
CovertError commented 6 months ago

i can create a demo project showing the issue if that helps

CovertError commented 6 months ago

@SNH-48 @zengqq1997 @Yeastar-PBX thanks for everything

SNH-48 commented 6 months ago

i can create a demo project showing the issue if that helps

yes, you can.

SNH-48 commented 6 months ago

I tried doing this replacing the information with our information and what i get is this and I'm using google chrome my project is running on TALL Stack and I'm using vite for asset https://vitejs.dev/ please let me know if there is something I'm missing

ys-webrtc-sdk-ui.js?v=a4c45421:24605 Uncaught Error: Automatic publicPath is not supported in this browser
    at ys-webrtc-sdk-ui.js?v=a4c45421:24605:19
    at ys-webrtc-sdk-ui.js?v=a4c45421:24607:10
    at ys-webrtc-sdk-ui.js?v=a4c45421:24608:8
    at ys-webrtc-sdk-ui.js?v=a4c45421:9:82
    at node_modules/ys-webrtc-sdk-ui/lib/ys-webrtc-sdk-ui.js (ys-webrtc-sdk-ui.js?v=a4c45421:10:6)
    at __require (chunk-34KZWS7D.js?v=a4c45421:5:50)
    at ys-webrtc-sdk-ui.js?v=a4c45421:24612:16
import { init } from 'ys-webrtc-sdk-ui';
const container = document.getElementById('container');
// Initialization
init(container, {
    username: '1000',
    secret: 'sdkshajgllliiaggskjhf',
    pbxURL: 'https://192.168.1.1:8088'
}).then(data => {
    const { phone, pbx, destroy, on } = data;
    console.log(data);
}).catch(err=>{
    console.log(err)
});

It seems your index.html use the <script src="%publicPath%/ys-webrtc-sdk-ui.js"></script> to require sdk-ui ?

SNH-48 commented 6 months ago

https://github.com/SNH-48/vue-with-ys-webrtc-sdk-ui-exmaple
here repo for you, you can see the HelloWorld.vue component how it work. @CovertError