logCustom method

Future<bool> logCustom(
  1. List<NotificationMessage> messages,
  2. String topic
)

logCustom @since 4.1.0

Implementation

Future<bool> logCustom(
  List<NotificationMessage> messages,
  String topic,
) async {
  if (messages.isNotEmpty &&
      messages.length <= _logCustomMessagesLimit &&
      topic.isNotEmpty &&
      topic.length <= _logCustomTopicLengthLimit) {
    bool result = true;
    for (final message in messages) {
      final Map<String, dynamic> data = {
        'action': 'custom',
        'topic': topic,
        'template_key': message.notificationData?.templateKey ?? '',
        'channel_url': message.channelUrl,
        'tags': message.notificationData?.tags ?? [],
        'message_id': message.notificationId,
        'source': 'notification',
        'message_ts': message.createdAt,
      };

      if (!await SendbirdStatistics.appendStat(
        type: SendbirdStatistics.notiStatsType,
        data: data,
      )) {
        result = false;
      }
    }
    return result;
  }
  return false;
}