addPushChannels method

Future<AddPushChannelsResult> addPushChannels(
  1. String deviceId,
  2. PushGateway gateway,
  3. Set<String> channels, {
  4. String? topic,
  5. Environment? environment,
  6. Keyset? keyset,
  7. String? using,
})
inherited

It registers device deviceId for push notifications from channels So the device deviceId will receive push notifications from those channels mentioned in list channels

deviceId is the id/token of the device gateway indicates the backend to use for push service it can be

  • apns or apns2 for apple service
  • gcm for google service
  • mpns for microsoft service

If gateway is PushGateway.apns2 then topic is mandatory to provide topic is bundle id of the mobile application environment denoting the environment of the mobile application for PushGateway.apns2 it can be either Environment.development or Environment.production default value for environment is Environment.development

Implementation

Future<AddPushChannelsResult> addPushChannels(
    String deviceId, PushGateway gateway, Set<String> channels,
    {String? topic,
    Environment? environment,
    Keyset? keyset,
    String? using}) async {
  keyset ??= keysets[using];

  Ensure(deviceId).isNotEmpty('deviceId');
  if (gateway == PushGateway.apns2) Ensure(topic).isNotNull('topic');

  var params = AddPushChannelsParams(keyset, deviceId, gateway, channels,
      topic: topic, environment: environment);
  return defaultFlow<AddPushChannelsParams, AddPushChannelsResult>(
      keyset: keyset,
      core: this,
      params: params,
      serialize: (object, [_]) => AddPushChannelsResult.fromJson(object));
}