The browser arouses QQ to carry on the chat some pit and the solution – small fission

Time:2020-11-21
Small fission wechat ecological user fission Growth Expert
Small fission website: www.xiaoliebian.com
The first WeChat ecosystem integration fission operation, official account fission, small program fission, community fission, personal number fission

explain

Calling QQ from the browser for chat is a customer service method that many companies or enterprises will use. However, many times, some mobile phone browsers do not support direct jump to QQ or jump to QQ page from the webpage embedded in app.

text

For jump to arouse QQ, QQ promotion of the official website http://shang.qq.com/v3/index…. To scan the QQ number to be called up for login, a code can be generated as follows:

<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=123456789&site=qq&menu=yes">
<img border="0"/>
</a>

The number “123456789” here is the QQ number that needs to be aroused.

With this method, QQ clients can be called up in most browsers, and the chat page can be located. However, this method will fail in the following cases:

  1. Apple’s Safari browser will prompt whether to open the link in the app store. If you select Yes, it will jump to the app store directly, and then you can jump to QQ. However, the parameters of the two jump transfers are lost, resulting in the inability to open the object that needs to be chatted.
  2. In mobile Google browser, the situation similar to 1 will also exist
  3. Web pages embedded in self-developed app, need to call QQ will also appear similar to 1.

Due to the high usage rate of safari browser in Apple mobile phone, we have to find another way for it according to the business demand.

Through understanding, it is found that the connection between apps can be solved through a technology called deep link. The so-called deep link is a kind of link technology that bypasses the homepage of the website and directly paginates links. For specific information, please see a blog post on linkedme https://www.linkedme.cc/blog/… 。

One of the solutions in deep linking is to define a new URL scheme, which can pass parameters to another app through a specific URI, thus changing the situation of independent non communication between apps.

To call QQ alone, or to solve the problem that Safari browser can’t call QQ, you can use the following URI:

mqqwpa://im/chat?chat_type=wpa&uin=123456789&version=1&src_type=web&web_src=oicqzone.com

The number “123456789” is the same QQ that needs to be aroused.

<a target="_blank" href="mqqwpa://im/chat?chat_type=wpa&uin=123456789&version=1&src_type=web&web_src=oicqzone.com">
 123456789
</a>

Through many tests, I sorted out the following different situations of QQ aroused by mobile browser (where no means the test was unsuccessful, and OK means the test was successful)

The browser arouses QQ to carry on the chat some pit and the solution - small fission

It needs to be mentioned here that URL scheme can not be used in various browsers of computers to arouse QQ, because URL scheme is specially proposed to solve the isolation between apps and is not suitable for computer applications. However, QQ can be used to promote the given scheme on the computer side.

We know how to solve the problem of APP jumping to QQ, but many times we hope to have a general solution to solve the above situations, ensuring that in most browsers (including computer browsers), only a set of code can solve the problem.

I personally distinguish the mobile browser from the computer browser by judging the user agent of the browser, and then provide different solutions for them

HTML code

<a href="javascript:void(0)" data-qq='qq'>111111111111</a>

Javascript code

window.onload = function () {

    var as = document.getElementsByTagName('a');

    var kefu101 = "http://wpa.qq.com/msgrd?v=3&uin=381232999&site=oicqzone.com&menu=yes";
    var kefu102 = "mqqwpa://im/chat?chat_type=wpa&uin=381232999&version=1&src_type=web&web_src=oicqzone.com";

    for (var i = 0, len = a.length; i < len; i++) {

        if (as[i].hasAttribute('data-qq')) {

            as[i].onclick = (function (i) {

                return function (e) {

                    var kefu = e.target ? e.target.getAttribute('data-qq') : e.srcElement.getAttribute('data-qq');

                    if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent) || /(Android)/i.test(navigator.userAgent)) {

                        window.open(kefu102);
                    }else {
window.open(kefu101);
                    }
                }
            })(i);
        }
    }
};

In this scheme, the mobile terminal uses URL scheme, and the computer side uses QQ promotion scheme.

Personal wechat: zmx119966 (welcome to exchange)