我使用 laravel-websockets 的 laravel 和 react-js 开发了一个反应应用程序,它运行良好!但是,当我想在react native 应用程序中使用它时,它会引发异常: ExceptionsManager.js:180 TypeError: Cannot read property 'presenceChannel' of undefined 我非常感谢您的时间,我希望有一个解决方案。
import Pusher from 'pusher-js/react-native'
import Echo from 'laravel-echo'
newEcho() {
Pusher.logToConsole = true;
let push = new Pusher('******',{
wsHost: 'push.******.com',
wssPort: 6001,
wsPort: 6001,
})
return new Echo({
broadcaster: push,
key: '********'
disableStats: true,
forceTLS: true,
authEndpoint: 'https://*******/broadcasting/auth',
auth: {
headers: {
Authorization: `Bearer ${API_TOKEN}`,
Accept: 'application/json',
},
},
});
}
componentDidMount() {
let EchoChannel = this.newEcho().join(`chat.${this.state.drtoken}`);
console.log(EchoChannel);
}