/ SDKs / Flutter
SDKs
Chat SDKs Flutter v4
Chat SDKs Flutter
Chat SDKs
Flutter
Version 4

Create a scheduled message

Copy link

You can create a scheduled user message to send at a later time by passing ScheduledUserMessageCreateParams as an argument to the createScheduledUserMessage() method.

// Create a scheduled user message.
final params = ScheduledUserMessageCreateParams(
  scheduledAt: DateTime.now().millisecondsSinceEpoch + 600000, // 10 minutes
  message: 'SCHEDULED_MESSAGE',
  translationTargetLanguages: ['ko', 'en'],
);

try {
  // The returned message is a pending message instance for the scheduled message.
  // It can be used in the same way as pending message from sendUserMessage().
  final pendingScheduledUserMessage = await groupChannel.createScheduledUserMessage(params);
} catch (e) {
  // Handle error.
}

You can also create a scheduled file message to send at a later time by passing ScheduledFileMessageCreateParams as an argument to the createScheduledFileMessage() method.

// Create a scheduled file message.
final params = ScheduledFileMessageCreateParams.withFile(
  FILE,
  scheduledAt: DateTime.now().millisecondsSinceEpoch + 600000, // 10 minutes
);

try {
  // The returned message is a pending message instance for the scheduled message.
  // It can be used in the same way as pending message from sendFileMessage().
  final pendingScheduledFileMessage = await channel.createScheduledFileMessage(params);
} catch (e) {
  // Handle error.
}