# onShareAppMessage

  • Listen to the user click the intra - page forward buttonbutton assembly open-type="share"), and customize the forwarding content.
  • Full documentation can be found in the Mini Program Documentation CenteronShareAppMessage , This article describes only the points of difference that this capability uses in a multi-tiered framework

Added: Under Multiterminal ModeshareThe ability is based on wx.miniapp.shareMiniProgramMessage Implementation, and therefore needs to be implemented in accordance with the wx.miniapp.shareMiniProgramMessageComplete the relevant initialization configuration (that is, you need to bind the mobile app account, check the opensdk Capacity expansion, etc.)

# Custom Forward Content in Mini Program Mode

field Introductions Default value
title Forward title Current applet name
path Forward path Current page path , must be in the form of / The full path at the beginning
imageUrl A custom image path, which can be a local file, a codepage file, or a graph of a network. Supports PNG and JPG. Show that the picture length breadth ratio is 5:4。 Use the default screenshot
promise If the parameter is present, the resolve The result shall prevail. If not within three seconds Resolve, the share will use the default parameter passed in above

# Content forwarded in multiterminal application mode

The following parameters are the same wx.miniapp.shareMiniProgramMessage

field Introductions Is required
userName Mini Program original ID, such as gh_d43f693ca31f,[Click to see how to get it](https://dev.weixin.qq.com/docs/framework/faq/dev.html#_1, how to get the Mini Program original -id) yes
path Mini Program page pathOnly local path support, not network path support yes
title title yes
description describe yes
imagePath Share thumbnails related to Mini Programs, support code package image resource path or local temporary, cache, user files (do not support network address) yes
webpageUrl Compatible with lower versions of web links url yes
withShareTicket Usually developers want to share the Mini Program to be opened a second time to get more information, such as the group identity. yes
MiniprogramType 0 - Official, 1 - Development, 2 - Experience yes
scene Send the target scene, only support the session, 0 = share to the session yes
promise If the parameter is present, the resolve The result shall prevail. If not within three seconds Resolve, the share will use the default parameter passed in above

sample code

Page({
  onShareAppMessage () {
    const promise = new Promise(resolve => {
      setTimeout (() => {
        resolve({
          userName: 'Mini Program original id ',  
          path: 'pages/index/index',
          title: The title,
          imagePath: '/pages/thumb.png',
          WebpageUrl:  'www.qq.com',
          withShareTicket: true,
          MiniprogramType:  0,
          scene: 0, 
        })
      }, 2000)
    })
    return {
      userName: 'Mini Program original id ',  
      path: 'pages/index/index',
      title: The title,
      imagePath: '/pages/thumb.png',
      WebpageUrl:  'www.qq.com',
      withShareTicket: true,
      MiniprogramType:  0,
      scene: 0, 
      promise 
    }
  }
})