APP and applet jump to each other

Keywords: less Session SDK Android

App and applet jump to each other: 1. App initiatively initiates the applet card to share with wechat, wechat clicks to open the applet, and then the applet can open App 2. App initiatively initiates to open the applet. Now the applet can open app mainly in these two ways. It seems inappropriate to jump to each other. After all, app is the active party, and the applet can only return passively Back, similar to sharing, if the app does not initiate sharing to wechat, wechat cannot return to your app. We should all have an impression here. As for the implementation method of the above two methods, it is also simple. As long as the wechat official website code is copied, it can be used. App actively shares app cards( WeChat official website ): applet beta cannot be shared

WXMiniProgramObject miniProgramObj = new WXMiniProgramObject();
miniProgramObj.webpageUrl = "http://www.qq.com "; / / compatible with lower version Web links
miniProgramObj.miniprogramType = WXMiniProgramObject.MINIPTOGRAM_TYPE_RELEASE;// Official version: 0, beta version: 1, experience version: 2
miniProgramObj.userName = "gh_d43f693ca31f";     // Applet original id
miniProgramObj.path = "/pages/media";            //Applet page path
WXMediaMessage msg = new WXMediaMessage(miniProgramObj);
msg.title = "Applet message Title";                    // Applet message title
msg.description = "Applet message Desc";               // Applet message desc
msg.thumbData = getThumb();                      // Applet message cover image, less than 128k
 
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("webpage");
req.message = msg;
req.scene = SendMessageToWX.Req.WXSceneSession;  // Session is currently supported
api.sendReq(req);

App proactively opens applet( WeChat official website):  

String appId = "wxd930ea5d5a258f4f"; // Fill in AppId
IWXAPI api = WXAPIFactory.createWXAPI(context, appId);
 
WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
req.userName = "gh_d43f693ca31f"; // Fill in the original id of the applet
req.path = path;                  //Pull the parameterized path of the applet page without filling in the default pull applet home page
req.miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE;// Open development version, experience version and official version
api.sendReq(req);
WXEntryActivity in
 
public void onResp(BaseResp resp) {
    if (resp.getType() == ConstantsAPI.COMMAND_LAUNCH_WX_MINIPROGRAM) {
        WXLaunchMiniProgram.Resp launchMiniProResp = (WXLaunchMiniProgram.Resp) resp;
        String extraData =launchMiniProResp.extMsg; // Corresponding to the extraData field data in JsApi navigateBackApplication
    }
}

It's easier for the applet to return to the App( WeChat official website):  

<button open-type="launchApp" app-parameter="wechat" binderror="launchAppError">open APP</button>

Another attachment: wechat sharing and opening App: it is realized by magic window SDK. In fact, it is web page that opens App. Apple can open App directly. Android can only use web page to open share and then open App. Specific implementation can be viewed Official website documents.

Posted by homer.favenir on Sat, 28 Dec 2019 07:29:05 -0800