Skip to content
On this page

Launch Miniprogram

launchMiniProgram

Launches a WeChat mini-program.

Type

typescript
function launchMiniProgram(request: {
  userName: string;
  path: string;
  miniProgramType: number;
  onNavBack?: (res: LaunchMiniProgramResponse) => void;
}): Promise<boolean>;

type LaunchMiniProgramResponse = NativeWechatResponse<{
  extMsg?: string;
}>;

Parameters

NameTypeRequiredDefault ValueDescription
userNameStringYes/User name of Wechat mini-program.
pathStringYes/Path.
miniProgramTypeNumberYes/Release:
NativeWechatConstants.WXMiniProgramTypeRelease
Preview:
NativeWechatConstants.WXMiniProgramTypePreview
Test:
NativeWechatConstants.WXMiniProgramTypeTest
onNavBack(res:LaunchMiniProgramResponse) => voidNo/When the mini-program navigates back to your App, this function will be called.

Example

typescript
import {launchMiniProgram} from 'native-wechat';

launchMiniProgram({
      userName: 'gh_6095mkozc213',
      path: '/pages/home/index',
      miniProgramType: NativeWechatConstants.WXMiniProgramTypePreview,
});

Released under the MIT License.