listSubscriptions method

Retrieves all push subscriptions for the channel.

Subscriptions can be filtered using a params object containing key-value pairs to filter subscriptions by. Can contain clientId, deviceId or a combination of both if concatFilters is set to true, and a limit on the number of subscriptions returned, up to 1,000.

Returns a PaginatedResult object containing a list of PushChannelSubscription objects.

Implementation

Future<PaginatedResult<PushChannelSubscription>> listSubscriptions(
    Map<String, String> params) async {
  if (!params.containsKey('deviceId') &&
      !params.containsKey('clientId') &&
      !params.containsKey('deviceClientId') &&
      !params.containsKey('channel')) {
    // This error only happen on Androids. They are thrown here
    // for both platforms (iOS/ Android) to make the API more consistent.
    throw AblyException(
      message: "expected parameter 'deviceId', 'clientId', "
          "'deviceClientId', and/or 'channel'",
    );
  }

  final message = await invokeRequest<AblyMessage<dynamic>>(
    PlatformMethod.pushListSubscriptions,
    {TxTransportKeys.params: params, TxTransportKeys.channelName: _name},
  );

  return PaginatedResult<PushChannelSubscription>.fromAblyMessage(
      AblyMessage.castFrom<dynamic, PaginatedResult<dynamic>>(message));
}