Js Method for deeplink

Source: Internet
Author: User

This article mainly introduces the js method for deeplink (determine whether the app is installed on the mobile phone). If you need it, refer

Code function:

Determine whether an app is installed on a mobile phone or tablet

If it is installed, the app's scheme is called, and the url is passed as a parameter for subsequent operations.

If not installed, go to app store/google play to download the app.

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;

}

})();

 

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.