The HTML to determine whether the phone installs an app, jump or download the app

Source: Internet
Author: User

Sometimes when you do a front-end output, you need to do some docking with your app. When you download an app in your mobile browser, you can tell if the app is installed by that user. If the app is installed, open the app directly, or download the app if it's not installed. Then the following is in the browser, with JS to determine whether a user installed the application, and determine whether to open the application to do a simple introduction.

So, how to tell if a user has installed an application?

Here, write a snippet of HTML code, as follows:

<!doctype html>head><meta charset= "Utf-8" >

Determine if an app is installed on the phone and open the application's JS code as follows:

function isInstalled () {var the_href=$ (". Down_app"). attr ("href");//Get Download link window.location= "Apps custom URL schemes"; /Open an app app on a phone settimeout (function () {window.location=the_href;//jump to the app download page},500 if timed out);}

Here is a simple explanation of the JS code: first try to open a mobile phone app on the local protocol, if the time-out to go to the app download page, download the app.

Here, someone is going to ask, how is this local agreement built? Well, here's a brief introduction to this:

In fact, it is in the app to convert the HTTP protocol into a local protocol, how to convert, not in this scope of discussion. However, you need to set the configuration file in the app (typically in the Manifest.xml file's activity's intent filter):

<span><intent-filter>                 <action android:name= "Android.intent.action.VIEW"/>                 < Category android:name= "Android.intent.category.DEFAULT"/>                 <category android:name= " Android.intent.category.BROWSABLE "/>                 <data               android:scheme=" * * "               android:host=" **.**               " android:pathprefix= "/**" >           </data>  </intent-filter></span> 

What is the apps custom URL schemes ?

is actually a protocol URL that you agree with the app, and you can set a URL Scheme in the iOS client or Android client. For example, set the URL Scheme:app, and then other programs can invoke the app via " urlstring=app://". You can also pass parameters, such as: app://reaction/?uid=1

The above describes how to create the local protocol and invoke the local protocol method. But here's another key is how to tell if the user installed the app? The principle is as follows:

In the mobile browser with the JS code to request the protocol, if within 500MS, if an application can resolve the protocol, then you can open the app, if more than 500ms jump to the app download page.

The HTML to determine whether the phone installs an app, jump or download the 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.