Skip to content
On this page

Share Miniprogram

shareMiniProgram

Shares a Wechat mini-program to chat.

Type

typescript
function shareMiniProgram(request: {
  userName: string;
  path: string;
  miniProgramType: number;
  webpageUrl: string;
  withShareTicket?: boolean;
  title?: string;
  description?: string;
  coverUrl?: string;
}): Promise<boolean>;

Parameters

NameTypeRequiredDefault ValueDescription
userNameStringYes/User name of Wechat mini-program.
pathStringYes/Path.
miniProgramTypeNumberYes/Release:
NativeWechatConstants.WXMiniProgramTypeRelease
Preview:
NativeWechatConstants.WXMiniProgramTypePreview
Test:
NativeWechatConstants.WXMiniProgramTypeTest
webpageUrlStringYes/If the version of WeChat is incompatible with the mini-program to be shared, a webpage will be opened instead.
withShareTicketBooleanNofalseIndicates whether to share with shareTicket.
titleStringNo/Message title.
descriptionStringNo/Description.
coverUrlStringNo/Message cover image.

Example

typescript
import {shareMiniProgram, NativeWechatConstants} from 'native-wechat';

shareMiniProgram({
      userName: 'gh_6e95p0mnc213',
      path: '/pages/home/index',
      miniprogramType: NativeWechatConstants.WXMiniProgramTypePreview,
      webpageUrl: 'https://hector.im',
});

Released under the MIT License.