tencent cloud

Feedback

React Native

Last updated: 2024-11-20 16:21:02

    Overview

    When sending a message, the user may want to switch to another chat window before finishing the message. The unfinished message can be saved through the setConversationDraft API, so that the user can get back to it through the draftText field of the Conversation object and finish it.
    Note:
    1. A conversation draft can contain only text.
    2. A conversation draft will be stored only in the local database and not on the server. Therefore, it cannot be synced across devices and will not be available after the application is uninstalled and reinstalled.

    Effect

    You can achieve the conversation draft effect shown in the figure below using this feature. Click on that conversation to enter the chat interface, and the draft content will automatically be filled into the input box:
    
    
    

    Setting a Conversation Draft

    API
    chat.setConversationDraft(options);
    Parameters
    Name
    Type
    Description
    conversationID
    String
    Conversation ID, which consists of:
    C2C${userID} (for one-to-one chats)
    GROUP{groupID} (for group chats)
    draftText
    String
    draft content, passing an empty string '' indicates canceling the draft.
    Returned value
    Promise
    Example
    let promise = chat.setConversationDraft({
    conversationID: 'GROUPpublic1',
    draftText: '123'
    });
    promise.then(function(imResponse) {
    }).catch(function(imError) {
    console.warn('setConversationDraft error:', imError);
    });
    // Canceling a conversation draft
    let promise = chat.setConversationDraft({
    conversationID: 'GROUPpublic1',
    draftText: ''
    });
    promise.then(function(imResponse) {
    }).catch(function(imError) {
    console.warn('setConversationDraft error:', imError);
    });
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support