You can create a scheduled user message to send at a later time by passing ScheduledUserMessageCreateParams as an argument to the createScheduledUserMessage() method.
JavaScriptTypeScript
// const sb = SendbirdChat.init(...); // For Sendbird Chat SDK initialization details, refer to:
// https://sendbird.com/docs/chat/sdk/v4/javascript/getting-started/send-first-message#2-get-started-3-step-2-initialize-sendbird-chat-sdk
// Create a scheduled user message.
const params = {
message: 'Off work, WOOHOO!',
scheduledAt: TODAY_AT_SIX_PM,
};
channel.createScheduledUserMessage(params)
.onPending((message) => {
// Pending scheduled message is received.
})
.onSucceeded((message) => {
// Scheduled message is received.
})
.onFailed((err, message) => {
// An error is received. Failed message is null.
});
const handler = new GroupChannelHandler();
handler.onMessageReceived = (channel, message) => {
// Sent scheduled message is received.
};
sb.groupChannel.addGroupChannelHandler('groupChannelHandler', handler);
You can create a scheduled file message to send at a later time by passing ScheduledFileMessageCreateParams as an argument to the createScheduledFileMessage() method.
JavaScriptTypeScript
// Create a scheduled file message.
const params = {
file: FILE,
scheduledAt: TODAY_AT_SIX_PM,
};
channel.createScheduledFileMessage(params)
.onPending((message) => {
// Pending scheduled message is received.
})
.onSucceeded((message) => {
// Scheduled message is received.
})
.onFailed((err, message) => {
// An error is received. Failed message is null.
});
const handler = new GroupChannelHandler();
handler.onMessageReceived = (channel, message) => {
// Sent scheduled message is received.
};
sb.groupChannel.addGroupChannelHandler('groupChannelHandler', handler);