How to open and jump to WeChat App from SMS link

The operation made an event and was going to send a text message to promote it. As a result, the problem came. After the user received the text message, he clicked on the link in the text message. By default, the system browser was used to open it, but our event was paid by WeChat~~ ~WeChat payment~~~

The system browser does not support it! ! !

How to let the user open WeChat after clicking the link?

I searched the Internet and found that the official applet actually provided a solution

Here we mainly discuss how to open applets through URL Scheme

First go to the official document link:

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

After the URL Scheme is obtained, it can be used to open the Mini Program from text messages, emails, and web pages outside of WeChat. The generated URL Scheme is as follows:

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

The iOS system supports identifying URL Schemes, and can directly jump to applets through Schemes in application scenarios such as text messages.

The Android system does not support direct recognition of URL Schemes. Users cannot open applets normally through Sheme. Developers need to use the H5 page to transfer, and then jump to Scheme to open the applet. The jump code example is as follows:

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

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

How to get the URL Scheme

There are two steps to get URL Scheme

1. Obtain the globally unique background interface call credential (access_token) of the Mini Program;

Second, use the access_token as a parameter to request to obtain the scheme code of the applet.

The specific interfaces and parameters are not detailed here. You can read the official documents, which are very clear.

But there is a pit in the official document. Here I have to remind you that when the scheme is obtained in the second step, the official description is as follows:

Hmm... request parameter access_token...

Then I started writing like this

 

The result keeps reporting access_token missing to me

After many investigations, I found that the access_token needs to be sent as a query on the requested url, not as a parameter in the body of the post. Do you think the official document is misleading~

The correct way of writing should be like this:

Then successfully obtained the Scheme

Ok, one last flow chart


That's all for today's sharing

Guess you like

Origin blog.csdn.net/weixin_49707375/article/details/128001550