Home - Webxdc Specification

sendToChat

let promise = window.webxdc.sendToChat(message);

sendToChat() allows a webxdc app to prepare a message that can then be sent to a chat by the user. Implementations may ask the user for a destination chat and then set up the message as a draft, so it is clear that the outgoing message is a result of some user interaction.

message is an object with file, text or both set:

The text can usually be modified by the user and the user may decide to send the text without the file or abort sending at all. These user decisions are not reported back to the webxdc app.

To let the user focus on sending the message, calling this function may pass control back to the main app and exit the webxdc app. The promise may or may not be resolved before exit.

In case of errors, the app will not exit and the promise will be rejected.

Example:

window.webxdc.sendToChat({
    file: {base64: "aGVsbG8=", name: "hello.txt"},
    text: "This file was generated by GreatApp"
}).catch((error) => {
    console.log(error);
});

Notes: