To open the app's implementation code by scanning two-dimensional code _javascript tips

Source: Internet
Author: User

Recently a friend asked small make up such a problem, first to everyone said the project needs: Scan two-dimensional code open app if the user does not have this app then prompts it to jump.

Using the Web page directly to invoke the app is not possible, you must first do some configuration.

First, the way Android and Apple are invoked is different.

So we need to judge the terminal first.

var u = navigator.useragent,
app = navigator.appversion;
var isandroid = u.indexof (' Android ') >-1 | | U.indexof (' Linux ') >-1; Android Terminal or UC browser
var Isios =!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/); iOS terminal

Then it is best to jump to two different pages to do the operation, because Apple needs to configure a App-id<meta in the head name= ' Apple-itunes-app ' content= ' app-id=1115968341 ' >

Here's the Apple code.

<! DOCTYPE html>
 
 

The ifr.src here is where you open the app's protocol path, and Android and Apple are different. <br><br><br> if it's Andro, it's easy.

<! DOCTYPE html>
 
 

This is our original demand, then changed, said that the Apple directly jump into the App store inside is good, do not open directly, Android words need to open directly.

So I'll just put them all together on a Web page.

I above the A link is a direct jump to Tencent application treasure inside.

Scanning with web pages is no problem,

But I felt that there would be an accident, and then took a micro-letter sweep on the force. Android will only open a link, jump not into the app, because it was intercepted by micro-letter, Apple is the same, the solution can only be clicked on the upper right corner, prompting the user to open the browser is no problem. This method is helpless, but then for the Apple machine to find a solution to its solution is, a link jump direct jump Tencent application treasure shelves of links, and then the micro-letter will be processed to help you automatically jump to the App store inside.

Finally, the code is integrated.

<! DOCTYPE html>
 
 

Add:

Scan two dimensional code jump app

1, to determine whether the installation of the app

 

2, open Project project target inside the Schemurl append://

The above is a small set to the introduction of the scanning two-dimensional code to open the app's implementation code, hope to help everyone, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.