Skip to content

ShareMiniProgram

Parameters

PropertyTypeDefault ValueRequiredDescription
userNamestring-YesMini Program original ID, such as gh_d43f693ca31f
pathstring-YesMini Program page path; for mini games, only the query part can be provided to achieve parameter passing, e.g., "?foo=bar"
titlestring-NoMini Program title
descriptionstring-NoMini Program description
imagePathstring-YesThumbnail image related to the mini program, supports code package image resources or local temporary, cached, or user files; network image paths are not supported
webpageUrlstring-YesWeb link URL for compatibility with older versions
withShareTicketstring-YesIf developers want the shared mini program to obtain more information when it is opened again, such as group identifiers, set withShareTicket to true. When the share card is opened by other users in a group chat, you can obtain shareTicket to get more share information. See Mini Program for more share information. Minimum client version required: 6.5.13
miniprogramTypenumber-Yes0-Official version, 1-Experience version, 2-Preview version
scenenumber-NoTarget scene for sharing, only supports chat, 0=share to chat

Example

javascript
window.Wechat.shareMiniProgram({
     webpageUrl: "https://byteee.fund",
     title: "XX小程序",
     description: "这是一个小程序",
     imagePath: "www/img/logo.png",
     userName: "gh_67210fc11b59",
     path: "/pages/index",
     miniprogramType: 0,
     withShareTicket: true,
  }, function(res){
    console.log("share success");
  }, function(err) {
    console.error(err);
  }
);

Apache 2.0 License.