May 18, 2021 WeChat Mini Program Development Document
This feature requires an active user trigger to open the APP, so it is not called by the API and needs to be triggered by a click of the button component with the value of open-type set to launchApp.
When a small program opens a scene from an APP sharing message card (scene value 1036, APP shares a small program document iOS/Android) or a scene opened from an APP (scene value 1069), the applet gets the ability to open the APP, at which point the user clicks a button to open the app that shares the applet card/pulls up the applet. That is, the small program can not open any APP, can only jump back to APP.
During the life of a small program, the ability to open an APP is only available under certain conditions.
In the version of the base library, slt; 2.5.1, the rules for this capability are as follows:
When a small program opens from a 1069 scene, you can open the APP.
When a small program opens from a non-1069, a state is managed inside the program framework, app can be opened for true, app cannot be opened for false. Maintenance of this state follows the following rules:
At the base library> = 2.5.1, this ability is as follows:
When the applet is opened from any scenario, a state will manage within the small program framework, to True, you can open the app, which is not possible to open the app.Maintenance of this state follows the following rules:
You need to set the value of the Button component Open-Type to Launchapp.If you need to pass parameters to the app while opening the app, you can set the app-parameter as the parameters to be passed.An error event that opens the app is listened to BindError.
App needs access to OpenSDK.Please refer to the documentation iOS / Android
Android third-party apps need to handle WeChat callbacks from ShowMesageFromWX.req, and iOS needs to add appId to the plist file URL type field that the third-party app project belongs to. For app-parameter acquisition methods, parameter parsing refer to the onResp method in WXEntryActivity in Android SDKSample and the onResp method in WXApiDelegate in iOS SDKSample.
<button open-type="launchApp" app-parameter="wechat" binderror="launchAppError">打开APP</button>
Page({
launchAppError (e) {
console.log(e.detail.errMsg)
}
})
Value | Description |
---|---|
invalid scene | The call scenario is incorrect, i.e. the small program at this time does not have the ability to open the APP. |