onAuthorizer method

dynamic onAuthorizer(
  1. String channelName,
  2. String socketId,
  3. dynamic options
)

Implementation

dynamic onAuthorizer(
    String channelName, String socketId, dynamic options) async {
  try {
    var token = await StorebountyAuth.checkIfUserIsLoggedIn();
    var clientId = 'storebounty';
    print("hhjdsf jsdhfjdhf jhfsd ${token}");
    var url =
        'https://apis-dev.ibunchng.com/accounts/api/v1/messaging/customers/authenticate?channel_name=$channelName&socket_id=$socketId';
    var result = await http.post(
      Uri.parse(url),
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': 'Bearer ${token}',
        'clientId': clientId,
        'channel': 'mobile'
      },
      body: 'socket_id=' + socketId + '&channel_name=' + channelName,
    );
    print("hhjdsf jsdhfjdhf jhfsd ${result.body}");
    var json = jsonDecode(result.body);

    print("hhjdsf jsdhfjdhf jhfsd ${json}");
    return json;
  } catch (e) {
    print(e);
  }
}