【发布时间】:2026-01-01 07:40:01
【问题描述】:
你好,我是反应原生的新手,我试图使用 pusher-js 创建一个实时聊天应用程序,所以我安装了包 npm install pusher-js @react-native-community/netinfo 并把我的 useEffect 中的以下代码
useEffect(() => {
// Enable pusher logging - don't include this in production
Pusher.logToConsole = true;
var pusher = new Pusher('REDACTED', {
cluster:"eu"});
var channel = pusher.subscribe('my-channel');
channel.bind('my-event', function(data) {
alert(JSON.stringify(data));
});
}, [])
我在控制台中得到了这个 Link of the image
我正在使用 react-native run-android 来运行并且我正在使用物理设备。 提前感谢您提供的所有帮助。
【问题讨论】:
-
我已经删除了您的应用程序密钥 - 您还应该考虑轮换 Pusher Dashboard 中的密钥以防止未经授权的使用。
标签: javascript react-native error-handling pusher pusher-js