The js method of of for deeplink determines whether the phone has an app

  • 2020-03-30 02:32:18
  • OfStack

Code functions:
Determine if you have an app on your phone/tablet
If installed, the scheme of the app is called, and the url is passed in as a parameter for subsequent operations
If not, jump to the app store/ Google play to download the app

(function() {
var openUrl =;
openUrl = openUrl.substring(1,openUrl.length);
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://[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";
window.location.href = openUrl;

Related articles: