React Native pusher onAuthrization不工作。它的工作为公共频道,但当我尝试为私人然后onAuthorization不工作
useEffect(() => {
getConnectToPusher();
}, []);
const getConnectToPusher = async () => {
console.log('Calling')
const pusher = Pusher.getInstance();
const channels = {};
await pusher.init({
apiKey: '',
cluster: 'ap1',
onAuthorizer: (channelName, socketId) => {
console.warn(channelName, socketId)
},
onError(message, code, e) {
console.log(`onError: $message code: ${code} exception: ${e} message= ${message}`);
}
});
await pusher.connect();
const myChannel = await pusher.subscribe({
channelName: 'private-my-channel',
onSubscriptionSucceeded: (channelName, data) => {
console.log(`Subscribed to ${channelName}`);
console.log(`I can now access me: ${myChannel.me}`)
console.log(`And here are the channel members: ${myChannel.members}`)
},
onEvent: (event) => {
console.log(`Event received: ${event}`);
},
});
}
1条答案
按热度按时间u5rb5r591#
我是这样使用授权器的