Home> headlines> body text

Example sharing of js in WeChat, Weibo, QQ, and Huo App

小云云
Release: 2018-01-24 16:20:51
Original
2405 people have browsed it

In this article, we mainly share with you examples of js in WeChat, Weibo, QQ, and Huo App. The user clicks to open the App or download button (this button may be on the top or bottom of a download entry page or various sharing pages. banner), if the user has installed the App, it will jump to the corresponding Native page according to the business; if the user has not installed the application, it will jump to the AppStore or App Market to download our App.

A complete process

Example sharing of js in WeChat, Weibo, QQ, and Huo App

First of all, all download/recall entries are direct jumps, which should be like this:

下载
Copy after login

Or like this:

window.location.href = 'https://applink-party.mtime.cn/mtlf'
Copy after login

All business judgments are made inmtlfThis page has two advantages:

  • Code shared by multiple businesses. In a team, everyone's business may have a banner download, and there is no simpler way to call it than locating it to a URL

  • Be able to useuniversal link

Let’s briefly talkuniversal link

Before iOS9, the evocation method was the same as that of Android now, both usingschemeCall up, this method has a small problem. Every time it is called up, a prompt will be given: whether to open the xx application, which allows the user to take one more step in terms of experience.universal linkwill jump directly and will not stay on the page. The condition is to add aapple-app-site-association.jsonfile in the root directory of our project, inside The content is roughly like this:

Example sharing of js in WeChat, Weibo, QQ, and Huo App

Then configure the iOS App background to realize direct arousal!

The evocation scheme of WeChat, Weibo, QQ, and Safari on various platforms

Example sharing of js in WeChat, Weibo, QQ, and Huo App
After a long period of experiments, we have summarized the effectiveness of this article on various platforms In this case, we will talk about the solutions to the success/failure of evocation one by one.

微信

WeChat is the most important sharing channel, but there is not much we can do. Previously, WeChat underiOSsupporteduniversal linkthis evocation method, but after January 8, 2018,WeChat blocked this! ! ! No matter what the reason is for WeChat to block this most convenient method of arousal underiOS, all we can do is adapt. So, now whether it is iOS or Android, our processing method is the same:jumps directly to the application treasure. The iOS App Store will guide you to findAppStore, and the Android App Store will directly open the App (provided you have downloaded it)
Note: WeChat opensitunesThe link is also blocked, so there is no way to jump directly toAppStore. We can only use the app to build this bridge.

微博

Weibo currently also supportsuniversal linkevocation, we only need to consider the situation of not downloading.

  • UnderiOS, Weibo does not support opening links to app treasures, so we need to guide users to open them usingSafari, like this :

Example sharing of js in WeChat, Weibo, QQ, and Huo App

  • ##Under the

    androidplatform,useschemeThis method cannot evoke the App, but there are exceptions. The sameschemecan be evoked by adult comments and NetEase Cloud Music. You can try it yourself if you have time. , so we can infer that Weibo under the Android platform also has a whitelist similar to WeChat. Those in the whitelist can be evoked usingscheme, just like WeChat does to JD.com, and JD.com does to WeChat It is evoked throughscheme.

so, whether it is

iOSorandroid, our solution is:directly guide the user to open it using a local browser.

QQ

  • iOSplatform, QQ currently also supportsuniversal linkto evoke. If it is not installed, QQ can also Supports directly openingituneslinks. Compared with other applications, QQ support is the best.

  • android平台下,QQ也支持scheme方式唤起,但是在一些老机型下,QQ会有一定的概率唤起失败,具体的现象是:第一次打开页面,唤起失败,再次打开,唤起成功。根据现象,我们可以推测出,在QQ的webview中,会对scheme的唤起方式做一些加载时间上的限制,经测试,大约在500ms,超过这个时间值,就会出现唤起失败的情况。为什么第二次打开,唤起成功的概率会大,是因为第一次加载时,已缓存了文件,第二次打开直接加载,这样时间在限制之内。

Safari

Safari这种情况比较简单,支持universal link,也支持直接打开itunes,so,如图处理就可以了。

踩坑

Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C202 MicroMessenger/6.6.1 NetType/WIFI Language/zh_CN
Copy after login
  • iOS-QQ

Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C202 QQ/7.3.5.473 V1_IPH_SQ_7.3.5_1_APP_A Pixel/1125 Core/UIWebView Device/Apple(iPhone X) NetType/WIFI QBWebViewType/1
Copy after login
  • iOS-微博

Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C202 Weibo (iPhone10,3__weibo__8.1.0__iphone__os11.2.2)
Copy after login
  • iOS-safari

Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Version/11.0 Mobile/15C202 Safari/604.1
Copy after login
  • android-微信

Mozilla/5.0 (Linux; Android 4.4.2; PE-TL20 Build/HuaweiPE-TL20; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/6.2 TBS/043807 Mobile Safari/537.36 MicroMessenger/6.6.1.1220(0x26060135) NetType/WIFI Language/zh_CN
Copy after login
  • android-QQ

Mozilla/5.0 (Linux; Android 4.4.2; PE-TL20 Build/HuaweiPE-TL20; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/6.2 TBS/043807 Mobile Safari/537.36 V1_AND_SQ_7.3.2_762_YYB_D QQ/7.3.2.3350 NetType/WIFI WebP/0.3.0 Pixel/1080
Copy after login
  • android-微博

Mozilla/5.0 (Linux; Android 4.4.2; PE-TL20 Build/HuaweiPE-TL20) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36 Weibo (HUAWEI-PE-TL20__weibo__8.0.2__android__android4.4.2)
Copy after login

配置完成之后,就可以像我一样,在电脑上切换环境啦:

Example sharing of js in WeChat, Weibo, QQ, and Huo App

大家学会了吗?觉得有用的赶紧收藏起来吧。


相关推荐:


H5的页面中怎样调用APP功能


H5混合开发app如何升级


h5怎样唤醒app

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!