wx.miniapp.shareTextMessage

View Markdown

Last edited on 2026-07-14

Share a text message to WeChat

Note:

  1. This API is only applicable to multi-end applications and is not supported within Mini Program.

  2. This API does not support debugging in the "Mobile App Assistant." Developers must build an APK or IPA and install it on a mobile device to perform debugging.

  3. This API is now supported on HarmonyOS devices.

Pre-integration Notes

Parameters

For developer convenience, the parameters of wx.miniapp.shareImageMessage are consistent with those of the WeChat Open Platform Open SDK Share API.

Attribute Type Default Value Required Description
text string - Yes The text to be shared
scene number - Yes The target scenario for sending. 0 = Share to chat, 1 = Share to Moments, 2 = Share to Favorites

JSAPI Code Example

wx.miniapp.shareTextMessage({
    text: 'Share a moment',
    scene: 0, // Share to conversation
    success(res) {
        wx.showToast({
            title: 'Success: Share text',
        })
    },
    fail() {
        wx.showToast({
            title: 'Failure: Share text',
        })
    }
})