React native custom host pusher connection

问题描述 投票:2回答:1

pusher log似乎无法连接到推杆。我已经在这些工作了几天,似乎无法连接到Pusher。版本6.0.3

 import Pusher from 'pusher-js/react-native';

componentDidMount() {
    this.willFocusSubscription = this.props.navigation.addListener(
        'willFocus',
        () => {

            try {
                this.pusher = new Pusher('DOCKOTO_KEY', {
                    wsHost: 'test.dockoto.com',
                    wsPort: 6001,
                    enabledTransports: ['ws'],
                    disableStats:true,
                });
                Pusher.log = (msg) => {
                    console.log('Pusher message ' + msg);
                };
            } catch (error) {
                console.log('error', error)
            }

            this.group_channel = this.pusher.subscribe('groupchat.' + session_id);
            this.pusher.connection.bind('GroupMessageSent', (data) => {
                console.log('connected', data)
            });
            this.group_channel.bind('GroupMessageSent', (data) => {
                console.log('data', data)
            });


        })
}

Pusher message Pusher::[“正在连接”,{“ transport”:“ xhr_polling”,“ url”:“ https://sockjs-4444.pusher.com:443/pusher/app/DOCKOTO_KEY?protocol=7&client=js&version=6.0.3”}]]

reactjs react-native pusher pusher-js
1个回答
0
投票

按照pusher文档肯定会为您提供帮助https://pusher.com/tutorials/chat-react-native

© www.soinside.com 2019 - 2024. All rights reserved.