H5 evoke app

Source: Internet
Author: User

H5 evokes App1. Determine if Open in

regardless of the platform on which the client Android/ios, access on the platform has a problem, that is unable to start the client, this is for security considerations , Android this block schema protocol, unless the company is a partner to join the white list to use, The iOS system can access the app's download page for AppStore, but it often blocks AppStore's URL from being accessed. The easy way to do this is in the browser, whether it is iOS or Android go to the app Bao download (iOS end will go to AppStore) page opens.

var agent = navigator.userAgent || ''var isWx = /micromessenger/i.test(agent)if(isWx){    //,提示用户用浏览器打开}else{    //非}

The JS Test () method is used to detect whether a string matches a pattern.

RegExpObject.test(string)   //string为要检测的字符串。//如果字符串 string 中含有与 RegExpObject 匹配的文本,则返回 true,否则返回 false。
2. Determine if the iOS
var isIOS = /iPhone|iPad|iPod/i.test(agent)   //返回true/false
3. Evoke the app

H5 launch app is essentially through the URL scheme to open the app, an app can set one or more open their own URL scheme, the browser to access an app URL scheme, and then if the system installed the app, You will be asked for permission to open the app.

In fact, the browser app opens another App,ios can use the UIApplication Canopenurl method to detect whether URL scheme can open the corresponding app, and Android is a similar way.

Of course, if JS jump URL scheme does not respond, it also means that the phone does not install the app.

<a class='btn'>打开app</a>

If you need to jump to the app-specific page, add a URL after the URL scheme (URL scheme and URL are provided by the app developer. )

if (isIOS) {    $('.btn').attr('href','BonDayApp://' + url);} else {    $('.btn').attr('href','bondayapp://bonday.com/scheme?' + url);}

H5 evoke app

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.