我正在尝试使用以下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没有接收到post数据。目前我没有任何可能阻止请求的中间件。
有人能看出我哪里出错了吗?