【发布时间】:2018-08-09 22:48:34
【问题描述】:
我正在尝试使用以下 React Native 脚本对私人广播进行身份验证。
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Pusher from 'pusher-js/react-native';
export default class App extends React.Component {
componentWillMount() {
Pusher.logToConsole = true;
var pusher = new Pusher('*********', {
authEndpoint: 'http://app.pgm/api/authtest',
cluster: 'eu',
encrypted: true
});
const channel = pusher.subscribe('private-chat-1');
}
上面的内容被发布到下面的函数中,下面的函数在从 Postman 测试时返回一个身份验证令牌。但是,当我通过 React Native 运行应用程序时,我得到以下响应。
public function pusher(Request $request){
$pusher = new Pusher(config('broadcasting.connections.pusher.key'), config('broadcasting.connections.pusher.secret'), config('broadcasting.connections.pusher.app_id'));
echo $pusher->socket_auth($request->channel_name, $request->socket_id);
}
[exp] Pusher:无法检索身份验证信息。 0客户端必须经过身份验证才能加入私人或在线频道。见:https://pusher.com/docs/authenticating_users [exp] Pusher : 在 private-chat-1 上没有回调 pusher:subscription_error
这让我认为 Laravel 没有收到帖子数据。我目前没有任何可以阻止请求的中间件。
谁能看出我哪里出错了?
【问题讨论】:
-
你找到解决办法了吗,我也遇到同样的问题
标签: javascript laravel reactjs react-native pusher