Home > Web Front-end > JS Tutorial > body text

js method for deeplink (determining whether app is installed on the phone)_javascript skills

WBOY
Release: 2016-05-16 16:53:48
Original
1836 people have browsed it

Code function:
Determine whether the app is installed on the phone/tablet
If installed, call the app's scheme and pass in the url as a parameter for subsequent operations
If not installed, jump to the app store /google play download app

Copy code The code is as follows:

(function() {
var openUrl = window .location.search;
try{
openUrl = openUrl.substring(1,openUrl.length);
}catch(e){

}
var isiOS = navigator.userAgent.match('iPad')
|| navigator.userAgent.match('iPhone')
|| navigator.userAgent.match('iPod') , isAndroid = navigator.userAgent
.match('Android'), isDesktop = !isiOS&&!isAndroid;
if (isiOS) {
setTimeout(function () { window.location = "itms-apps: //itunes.apple.com/app/[name]/[id]?mt=8"; },25);
window.location = "[scheme]://[host]?url=" openUrl ;
}else if(isAndroid){
window.location = "intent://[host]/" "url=" openUrl "#Intent;scheme=[scheme];package=[package_name];end ";
}else{
window.location.href = openUrl;
}
})();

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
Popular Tutorials
More>
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!