App evoke small micro-channel program and callback

Mobile applications and applets in the same account without linking an open platform to complete the jump, a small program under the same open platform accounts to be associated with a mobile application (APP) after successfully supported jump.

In the "Management Center - Mobile Application - Application details - information related applets", initiated by the associated applets operation is approved mobile applications.

arouse

App opened his program in two ways:

1, App shared by the card applet to the micro channel, and then click the Open Card applet applets on the micro-channel, which is also open applet may App

The first step: You need to WeChat open platform will be associated with your app on your little program!
Step Two: You need to import the project have wechatOpenSDK
third step: Share Card Type applet
official document: https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id = open1419317332 & token = & lang = zh_CN
The first: an example of the type of text Share 
SendMessageToWXReq * REQ = [[SendMessageToWXReq alloc] the init]; 
    req.text = @ " share " ; 
    req.bText = YES; 
    req.scene = WXSceneSession; // currently only supports session in the form of 
    [ WXApi sendReq: req]; 

second: App proactive in sharing applets card: ⚠️ small beta program can not share 
WXMiniProgramObject * wxminiObiect = [WXMiniProgramObject Object ]; 
    wxminiObiect.webpageUrl = webpageUrl; // compatible with low version of the network link 
    wxminiObiect.userName the userName =; // original ID applet 
    wxminiObiect.path = path; //Specify the URL of a page to open the path to a small program 
    wxminiObiect.hdImageData = hdImageData; // applet node larger HD, less than 128K 
    
    WXMediaMessage * the Message = [WXMediaMessage the Message]; 
    message.title = @ " applet title " ; 
    the Message. the Description = @ " applet the Description " ; 
    message.mediaObject = wxminiObiect; 
    message.thumbData = nil; // compatible with older versions of the picture node, less than 32k, the new version of the priority 
    
    SendMessageToWXReq * REQ = [[SendMessageToWXReq alloc] the init]; 
    REQ. Message = Message; 
    req.sceneWXSceneSession =; // currently only supports session 
    
    return [WXApi sendReq: REQ];

2, App initiative by calling api to open the applet, this time the applet can also open App

The official document: https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=21526646385rK1Bs&token=&lang=zh_CN

* = LaunchMiniProgramReq WXLaunchMiniProgramReq [WXLaunchMiniProgramReq Object ]; 
    launchMiniProgramReq.userName = @ " gh_3413cfa14bae " ;   // original ID pull applet 
    launchMiniProgramReq.path = @ " Pages / index / index " ;     // pull applet pages may parameterized path, do not fill the default pull applet Home 
    launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; // type pull applet 
   [WXApi sendReq: launchMiniProgramReq]; 
// or String appId = " wxd930ea5d5a258f4f "; // fill in the application AppId IWXAPI API = WXAPIFactory.createWXAPI (context, appId); WXLaunchMiniProgram. Req req = new WXLaunchMiniProgram.Req (); req.userName = " gh_d43f693ca31f "; // Fill the original applet ID req.path = path; // pull applet path page can be parameterized, default do not fill pull since applets Home req.miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE; // optional open development version, trial version and official version api.sendReq (req);

WXMiniProgramTypeRelease official version WXMiniProgramTypeTest Developer Edition trial version WXMiniProgramTypePreview

Callback

When the applet scene share message from the card APP opening (scene value 1036, the applet file sharing APP iOS / Android) or opened from APP opening scene (scene value 1069), the ability to obtain the applet APP open, in which case users can click the button to open the program to share the small card / APP pull the applet. That applets can not open any APP, can only jump back to APP.

By micro letter described in this document, the program jumps back to childhood App can only jump back by clicking on the small button in the program, how to click the button to jump back to the App, and it carries the parameters, you need the following two steps

App end:

We need to create WXEntryActivty, achieve IWXAPIEventHandler interface rewrite onResp method. Note Acitvity need to be declared in the Manifest file android: exported = "true", so that it can be external to arouse

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 following applet app value -parameter field 
    } 
}

Applets end:

The required <button> assembly open-type set value to launchApp. If you need to pass parameters to the APP APP when opened, you can set the parameters app-parameter is to be transmitted. Open the error event can listen APP by binderror.

<view class='suspension'>
      <button class="server_button" open-type="launchApp" app-parameter="wechat" binderror="launchAppError">打开APP</button>
    </view>

Such content is the App to get wechat.

Spread 

The next step is to demand a plurality of small program jumps App, and then return the different App; an App different Jump applet returns accept different content.

Pull up a small path from the App page can be arguments, we will use this parameter to determine is a small program to jump from the App.

E.g:

App name is a path for the jump:

"pages/index/index?type=appA"

App name is a jump path b is:

"pages/index/index?type=appB"

Receives applet parameters:

the onLoad: function (Options) { 
    the console.log (options.type); // App based on the passed parameter a or B 
},

 

Guess you like

Origin www.cnblogs.com/joe235/p/11355891.html