I’m using pusher for the real time communication expecifically the messaging. but i’m getting this error
This is my implementation of init method.
Future<void> initPusher(String roomID) async {
_pusher = PusherChannelsFlutter.getInstance();
try {
await _pusher.init(
apiKey: pusherKey,
cluster: cluster,
logToConsole: true,
useTLS: true,
onConnectionStateChange: onConnectionStateChange,
onError: onError,
onSubscriptionSucceeded: onSubscriptionSucceeded,
onEvent: onEvent,
onSubscriptionError: onSubscriptionError,
onDecryptionFailure: onDecryptionFailure,
onMemberAdded: onMemberAdded,
onMemberRemoved: onMemberRemoved,
authEndpoint: "${CmApiEndpoints.baseUrl}/broadcasting/auth",
onAuthorizer: onAuthorizer,
);
//"presence-ChatRoom.$roomID"
await _pusher.subscribe(channelName: "ChatRoom.$roomID");
await _pusher.connect();
} catch (e) {
print("error in initialization: $e");
}
}
and the auth method
dynamic onAuthorizer(
String channelName, String socketId, dynamic options) async {
String token = userToken;
var authUrl = "${CmApiEndpoints.baseUrl}/broadcasting/auth";
var result = await dioClient().post(
authUrl,
data: 'socket_id=$socketId&channel_name=$channelName',
options: Options(
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer $token',
},
),
);
var json = jsonDecode(result.data);
return json;
}
New contributor
Syed Mahamudul Hasan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1