MessagingPayload constructor

MessagingPayload({
  1. Map<String, String>? data,
  2. NotificationMessagePayload? notification,
})

Implementation

MessagingPayload({this.data, this.notification}) {
  if (data == null && notification == null) {
    throw FirebaseMessagingAdminException(
      MessagingClientErrorCode.invalidPayload,
      'Messaging payload must contain at least one of the "data" or "notification" properties.',
    );
  }

  if (data != null) {
    for (final key in data!.keys) {
      if (_blacklistedDataPayloadKeys.contains(key) ||
          key.startsWith('google.')) {
        throw FirebaseMessagingAdminException(
          MessagingClientErrorCode.invalidPayload,
          'Messaging payload contains the blacklisted "data.$key" property.',
        );
      }
    }
  }
}