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