# open App
This feature requires the user to actively trigger to open App, so not by API To call, you need to use the open-type
The value of the launchApp
of button Component's click to trigger.
When the Mini Program starts from the APP When the open scene is open (the scene value 1069), the Mini Program will get the return APP The ability of the user to click the button to open the Mini Program to pull up the APP。That is, Mini programs cannot open arbitrary App, can only Jump back
APP。
During the life of an Mini Program, only under certain conditions, has the ability to open APP Ability, the rules for this ability are as follows:
When the Mini Program starts from the 1069 When the scene is open, you can open APP。
When the Mini Program is not 1069 A state that will be managed within the Mini Program framework when the true You can open the App, for false It cannot be opened. APP。Maintenance of this state follows the following rules:
- When the Mini Program is opened from the following scenario, keep the Mini Program open when you last opened it App State of Ability:
- When returning an Mini Program from another Mini Program (scene value 1038) (the base library 2.2.4 The above version is supported)
- The Mini Program from the top of the chat scene (scene value 1089)Recently UsedWhen the inside is opened
- Long press the top right menu of the Mini Program to call out the recent use history (scene value 1090)
- Discovery bar Mini Program main entrance,Recently UsedList (scene value 1001) when open (base library 2.17.3 and above support)
- Floating windows (scene values 1131, 1187) when open (base library 2.17.3 and above support)
- When an Mini Program is opened from a scene other than the above, it does not have the ability to open APP The ability to set this state to false。
# Methods of Use
# Mini Program end
The need to button assembly open-type
The value of the launchApp
If you need to open the APP Time direction APP Passing parameters, you can set the app-parameter
For the parameter to be passed. adopt binderror
Can listen to open APP Of the error event.
# sample code
<button open-type="launchApp" app-parameter="wechat" binderror="launchAppError">Open the app</button>
Page({
launchAppError (e) {
console.log(e.detail.errMsg)
}
})
# error Dxplaination of event parameters
value | Introductions |
---|---|
invalid scene | The call scenario is incorrect, that is, the Mini Program at this time does not have the ability to open APP The ability. |
# APP end
APP Need access OpenSDK。 Documentation please refer to the [iOS](https://developers.weixin.qq.com/doc/oplatform /Mobile_App/Access_Guide/iOS.html) / [Android](https://developers.weixin.qq.com/doc/oplatform /Mobile_App/Access_Guide/Android.html)
Android third party app Needs to be addressed ShowMessageFromWX.req
WeChat callback, iOS You will need to appId Add to Third Party app The project belongs to plist file URL types Fields.
app-parameter
The method of obtaining the parameter parsing, please refer to the Android SDKSample in WXEntryActivity to hit the target onResp Methods and iOS SDKSample in WXApiDelegate to hit the target onResp Method.
# iOS sample code
-(void)onResp:(BaseResp *)resp
{
if ([resp isKindOfClass:[WXLaunchMiniProgramResp class]])
{
NSString *string = or extMsg
// Corresponding Mini Program component <button open-type="launchApp"> to hit the target app-parameter attribute
}
}
# Android sample code
WXEntryActivity
public void onResp(BaseResp resp) {
if (respectively.getType () == ConstantsAPI.COMMAND_LAUNCH_WX_MINIPROGRAM) {
WXLaunchMiniProgram.Resp launchMiniProResp = (WXLaunchMiniProgram.Resp) resp
String extraData =launchMiniProResp.extMsg //Corresponding Mini Program component <button open-type="launchApp"> to hit the target app-parameter attribute
}
}
As your App Was launched using the platform[Multiterminal framework](https://dev.weixin.qq.com/docs/framework/utm _source=mp_docs_launchApp)Developed, you can just call the following JSAPI Can be easily achieved without the need to follow the above guidelines in Android or iOS Access during the project.
- [wx.miniapp.launchMiniProgram](https://dev.weixin.qq.com/docs/framework/dev/jsapi/Miniapp /launchMiniProgram.html) The interface has returned from the Mini Program App Encapsulates the callback contents of the
res.data
Can be obtained