The browser link jumps to the specified page of the applet (applicable to Android and iOS)

The external link of Android and ios browsers jumps into the applet.
Requirements: The user clicks on the link to enter the applet.
The first step:
the backend needs to cooperate with calling the official interface method provided by WeChat to generate the link of the applet.
The official document is as follows:
https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/url-scheme.html
insert image description here
Click on the red circled part to enter to view the method of generating a mini-program link. The appId of the applet and related parameters need to be provided to the backend.
For example, if these parameters are fixed, you can directly write them to the backend, depending on your business needs.

const {
    
     result } = await getAppLink({
    
    
       path: '/pages/service/service',
       query: `suid=0000`, // 可以携带到小程序页面得参数
       env_version: 'release'
     });

The backend calls the WeChat official interface to get the returned data.
insert image description here
The backend gets the openlink through the method and returns it to the frontend. Note that each generated link can only be used by the same user. If other users click it, it needs to be regenerated , the maximum validity period for each link is 30 days. It is recommended that every time the front end requests, the back end regenerates a link, which is more convenient.
Step 2:
The front end needs to process the link, and the way to jump the link is different between Android and ios.

try { window.location.href = result; (Android) } catch (error) { window.open(result); (iOS) } You can use this method to jump to the applet. end. WeChat official documents may change at any time, please refer to WeChat official documents for details






Guess you like

Origin blog.csdn.net/weixin_44227395/article/details/127422254