sendChannelMessage method
- required String channelArn,
- required String chimeBearer,
- required String content,
- required ChannelMessagePersistenceType persistence,
- required ChannelMessageType type,
- String? clientRequestToken,
- String? contentType,
- Map<
String, MessageAttributeValue> ? messageAttributes, - String? metadata,
- PushNotificationConfiguration? pushNotification,
- String? subChannelId,
- List<
Target> ? target,
Sends a message to a particular channel that the member is a part of.
Also, STANDARD messages can be up to 4KB in size and contain
metadata. Metadata is arbitrary, and you can use it in a variety of ways,
such as containing a link to an attachment.
CONTROL messages are limited to 30 bytes and do not contain
metadata.
May throw BadRequestException.
May throw ConflictException.
May throw ForbiddenException.
May throw ServiceFailureException.
May throw ServiceUnavailableException.
May throw ThrottledClientException.
May throw UnauthorizedClientException.
Parameter channelArn :
The ARN of the channel.
Parameter chimeBearer :
The ARN of the AppInstanceUser or AppInstanceBot
that makes the API call.
Parameter content :
The content of the channel message.
Parameter persistence :
Boolean that controls whether the message is persisted on the back end.
Required.
Parameter type :
The type of message, STANDARD or CONTROL.
STANDARD messages can be up to 4KB in size and contain
metadata. Metadata is arbitrary, and you can use it in a variety of ways,
such as containing a link to an attachment.
CONTROL messages are limited to 30 bytes and do not contain
metadata.
Parameter clientRequestToken :
The Idempotency token for each client request.
Parameter contentType :
The content type of the channel message.
Parameter messageAttributes :
The attributes for the message, used for message filtering along with a
FilterRule defined in the
PushNotificationPreferences.
Parameter metadata :
The optional metadata for each message.
Parameter pushNotification :
The push notification configuration of the message.
Parameter subChannelId :
The ID of the SubChannel in the request.
Parameter target :
The target of a message. Must be a member of the channel, such as another
user, a bot, or the sender. Only the target and the sender can view
targeted messages. Only users who can see targeted messages can take
actions on them. However, administrators can delete targeted messages that
they can’t see.
Implementation
Future<SendChannelMessageResponse> sendChannelMessage({
required String channelArn,
required String chimeBearer,
required String content,
required ChannelMessagePersistenceType persistence,
required ChannelMessageType type,
String? clientRequestToken,
String? contentType,
Map<String, MessageAttributeValue>? messageAttributes,
String? metadata,
PushNotificationConfiguration? pushNotification,
String? subChannelId,
List<Target>? target,
}) async {
final headers = <String, String>{
'x-amz-chime-bearer': chimeBearer.toString(),
};
final $payload = <String, dynamic>{
'Content': content,
'Persistence': persistence.value,
'Type': type.value,
'ClientRequestToken': clientRequestToken ?? _s.generateIdempotencyToken(),
if (contentType != null) 'ContentType': contentType,
if (messageAttributes != null) 'MessageAttributes': messageAttributes,
if (metadata != null) 'Metadata': metadata,
if (pushNotification != null) 'PushNotification': pushNotification,
if (subChannelId != null) 'SubChannelId': subChannelId,
if (target != null) 'Target': target,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/channels/${Uri.encodeComponent(channelArn)}/messages',
headers: headers,
exceptionFnMap: _exceptionFns,
);
return SendChannelMessageResponse.fromJson(response);
}