h5 page jumps to WeChat applet (the simplest method | URL Scheme)

Insert image description here


Introduction

The need for H5 page jumps to WeChat applet is universal. Since the WeChat applet is an application that can only be accessed within WeChat, and the H5 page can be accessed in any browser, a jump is required to achieve the connection between the two.
For users, H5 page jump WeChat applet can provide a better user experience. Users can browse and select goods, services and other content on the H5 page, and then jump directly to the WeChat applet for purchase, payment and other operations, avoiding switching and jumping between different platforms, improving efficiency and convenience. sex.
For enterprises and developers, H5 page jump WeChat applet can bring more business opportunities and value. By guiding users to jump to WeChat mini programs in H5 pages, you can increase user stickiness and conversion rates, and increase sales and revenue. At the same time, the development and maintenance costs of WeChat mini programs are relatively low, which can reduce the operating costs and threshold of enterprises.
The demand for H5 page jumps to WeChat mini programs is universal and can bring better user experience and corporate value. However, it should be noted that achieving this requirement requires certain technical capabilities and compliance with corresponding development specifications and requirements.

accomplish

Official document address: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/url-scheme.html

Get URL Scheme

Starting from December 19, 2023, URL Scheme will be upgraded. Detailed adjustment instructions can be found in the "URL Scheme and URL Link Optimization Announcement". An overview of the changes is as follows:

  1. Support developers to splice parameters behind the original encrypted URL Scheme;

  2. A new plaintext URL Scheme is added, developers can splice and generate plaintext Scheme by themselves without calling the interface;

  3. Cancel the URL Scheme restriction of one person and one link, and support the same connection to be accessed by multiple users;

  4. The maximum number of URL Scheme and URL Link openings per mini program per day is 3 million.

Encrypted URL Scheme

method of obtaining

The encrypted URL Scheme for opening any page of the mini program can be obtained through the server interface. Suitable for opening mini programs from text messages, emails, web pages outside WeChat, etc. The scenario value for opening a mini program through URL Scheme is 1065.
The generated URL Scheme is as follows:


  weixin://dl/business/?t= *TICKET*

The iOS system supports identifying URL Scheme, and can directly jump to mini programs through Scheme in application scenarios such as text messages.
The Android system does not support direct recognition of URL Scheme. Users cannot normally open mini programs through Scheme. Developers need to use H5 page transfer and then jump to Scheme to open the mini program. Examples of jump codes are as follows:

location.href = 'weixin://dl/business/?t= *TICKET*'

This jump method can be called immediately when the user opens H5, or after the user triggers an event.

Splicing parameters

Smoothly upgrade the original URL Scheme to an encrypted URL Scheme, allowing developers to splice CUSTOM PARAMETE behind the link. The URL Scheme after splicing the parameters is as follows:

weixin://dl/business/?t= *TICKET*&cq=*CUSTOM PARAMETER*

Notice:

  1. CUSTOM PARAMETE is a special query with a maximum length of 256 characters. It only supports numbers, uppercase and lowercase English and some special characters: !#$&'()*+,/:;=?@-._~%`, required url_encode;
  2. URL Schemes that have been generated before this rule adjustment takes effect can continue to be used normally, and CUSTOM PARAMETE parameters can be spliced ​​directly;
  3. The value of the encrypted URL Scheme after splicing the parameters when opening the mini program remains unchanged and is still 1065.

Plain URL Scheme

method of obtaining

Developers do not need to call the platform interface. After pulling up this applet declaration in MP Platform->Settings->Privacy and Security->Clear Text Scheme, they can splice parameters such as appid and path according to the following format as a plain text URL Scheme link.

weixin://dl/business/?appid=*APPID*&path=*PATH*&query=*QUERY*&env_version=*ENV_VERSION*

Among them, the definitions of each parameter are as follows:

  1. [Required] APPID: The appid of the mini program that is opened through plaintext URL Scheme;
  2. [Required] PATH: The page path to open the mini program through the clear text URL Scheme. It must be the page where the published mini program exists. Query cannot be carried;
  3. [Optional] QUERY: Open the query of the mini program through the clear text URL Scheme. The maximum length is 512 characters. Only numbers, uppercase and lowercase English and some special characters are supported: !#$&'()*+,/:;=?@- ._~%`, requires url_encode;
  4. [Optional] ENV_VERSION: The version of the mini program to be opened. The official version is release, the experience version is trial, and the development version is develop. It only takes effect when opened outside WeChat. Note: If not filled in, the official version of the mini program will be opened by default.

The scenario value for opening a mini program through plaintext URL Scheme is 1286.

Actual project display:

<body>
    <a href="weixin://dl/business/?appid=wx1234123123&path=pages/index/index">点击跳转</a>

</body>

Insert image description here
Click to jump. (When operating on a mobile phone, a computer can only jump to WeChat and not to mini programs)
Insert image description here

frequency limit

Generation end: The total number of URL Scheme (encrypted + plain text) and URL Link generated per day is capped at 500,000;

Open side: The total number of times a mini program can be opened through URL Scheme (encrypted + plain text) and URL Link is capped at 3 million per day.

Precautions

If you need to open a mini program on a webpage in WeChat, please use the WeChat open tab - mini program jump button. If you don't have a public account, you can also directly use the mini program identity to develop web pages and jump to the mini program without authentication. See the cloud development static website jump mini program. program. Mini programs that meet the open scope can send text messages that support opening mini programs.
This function basically covers the WeChat version currently used by users, and developers do not need to be compatible with lower versions. Only the
URL Scheme of published mini programs can be generated.
Jump through URL Scheme. When reaching WeChat, a system pop-up box may be triggered to ask. If the user chooses not to jump, the mini program cannot be opened. Developers are asked to properly handle the scenario where users choose not to jump.
Some browsers will restrict direct jumps when opening web pages. You can refer to the example web page to set the jump button.
The platform has security policies to prevent developers’ links from being opened in batches by black and gray products, resulting in The problem of not being able to open the mini program normally due to the upper access limit

Open range

Open to small programs for non-individual subjects.

Sample code package

https://download.csdn.net/download/weixin_48998573/88650342

Hello, I am Feichen.
Welcome to follow me to obtain front-end learning resources, daily sharing of technological changes and survival rules; industry insiders and insights.

Guess you like

Origin blog.csdn.net/weixin_48998573/article/details/135134309