heywhy / flutter-pusher-client

A pusher.com client written with dart for flutter
MIT License
9 stars 30 forks source link

Can't connect to a private channel "no Authorizer has been set" #12

Closed emrade closed 4 years ago

emrade commented 4 years ago

When I try to connect to a private channel I get the error "subscribe error: Cannot subscribe to a private or presence channel because no Authorizer has been set. Call PusherOptions.setAuthorizer() before connecting to Pusher".

Can you help me?

heywhy commented 4 years ago

You are to set the authorization information on the pusher client instance:

var options = PusherOptions(cluster: 'eu', auth: PusherAuth('https://app.com/broadcast/auth', headers: {
  'Authorization': "Bearer $token"
}));
FlutterPusher pusher = FlutterPusher('api_key', options, enableLogging: true,);
emrade commented 4 years ago

It would be great if you could add it to the docs or example. Thanks