MessagingOptions constructor

MessagingOptions({
  1. bool? dryRun,
  2. String? priority,
  3. int? timeToLive,
  4. String? collapseKey,
  5. bool? mutableContent,
  6. bool? contentAvailable,
  7. String? restrictedPackageName,
})

Interface representing the options that can be provided when sending a message via the FCM legacy APIs.

See Build send requests for code samples and detailed documentation.

Implementation

MessagingOptions({
  this.dryRun,
  this.priority,
  this.timeToLive,
  this.collapseKey,
  this.mutableContent,
  this.contentAvailable,
  this.restrictedPackageName,
}) {
  final collapseKey = this.collapseKey;
  if (collapseKey != null && collapseKey.isEmpty) {
    throw FirebaseMessagingAdminException(
      MessagingClientErrorCode.invalidOptions,
      'Messaging options contains an invalid value for the "$collapseKey" property. Value must '
      'be a boolean.',
    );
  }

  final priority = this.priority;
  if (priority != null && priority.isEmpty) {
    throw FirebaseMessagingAdminException(
      MessagingClientErrorCode.invalidOptions,
      'Messaging options contains an invalid value for the "priority" property. Value must '
      'be a non-empty string.',
    );
  }

  final restrictedPackageName = this.restrictedPackageName;
  if (restrictedPackageName != null && restrictedPackageName.isEmpty) {
    throw FirebaseMessagingAdminException(
      MessagingClientErrorCode.invalidOptions,
      'Messaging options contains an invalid value for the "restrictedPackageName" property. '
      'Value must be a non-empty string.',
    );
  }
}