Consider the question:
Typically, we develop an app that has an Android version and an iOS version.
But only one QR code? What do we do?
How to let iOS user scan qr code download iOS version, android user scan QR code to download to Android version?
Implementation ideas:
- First of all, we need to create a new HTML file, through JavaScript to determine the user's mobile phone system (iOS or Android), after judging, according to the different mobile system, jump to different links to download.
- We then use the address of this HTML file to generate a two-dimensional code image.
- Finally, the user can scan a two-dimensional code image for the corresponding download.
the code:down.html
12 34<meta http-equiv="Content-type"Content="text/html; Charset=utf-8"/>5<title> Two-dimensional code download </title>6 7<script type="Text/javascript">8 /* 9 * Smartphone browser version information:Ten * One */ A varBrowser = { - versions:function () { - varU =Navigator.useragent, theApp =navigator.appversion; - return{//Mobile Terminal browser version information -Trident:u.indexof ('Trident') >-1,//IE kernel -Presto:u.indexof ('Presto') >-1,//Opera Kernel +Webkit:u.indexof ('AppleWebKit') >-1,//Apple, Google kernel -Gecko:u.indexof ('Gecko') >-1&& U.indexof ('khtml') == -1,//Firefox kernel +Mobile:!! U.match (/applewebkit.*mobile.*/) | | !! U.match (/applewebkit/),//whether it is a mobile terminal AIos:!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/),//iOS terminal atAndroid:u.indexof ('Android') >-1|| U.indexof ('Linux') >-1,//Android Terminal or UC browser -Iphone:u.indexof ('IPhone') >-1|| U.indexof ('Mac') >-1,//whether it's an iphone or Qqhd browser -Ipad:u.indexof ('IPad') >-1,//whether ipad -Webapp:u.indexof ('Safari') == -1 //whether the web should program, no head with the bottom - }; - }(), inLanguage: (Navigator.browserlanguage | |navigator.language). toLowerCase () - } to + if(Browser.versions.ios | | browser.versions.iPhone | |browser.versions.iPad) { -Window.location ="Https://itunes.apple.com/cn/app/xxx"; the}Else if(browser.versions.android) { *Window.location ="http://zhj8.aliapp.com/xxx.apk"; $ }Panax Notoginseng - //Document.writeln ("language version:" + browser.language); the //Document.writeln ("Whether for Mobile Terminal:" + browser.versions.mobile); + //Document.writeln ("iOS terminal:" + Browser.versions.ios); A //Document.writeln ("Android Terminal:" + browser.versions.android); the //Document.writeln ("Whether for IPhone:" + browser.versions.iPhone); + //Document.writeln ("Whether IPad:" + browser.versions.iPad); - //Document.writeln (navigator.useragent); $</script> $ - -<body> the -</body>Wuyi theUse this down.html to generate a two-dimensional code image, and then use a mobile phone sweep can be.
Hope to be able to help everyone! If you have any questions, welcome to Dabigatran!
How does a QR code automatically identify Android (Android) or Apple (IOS)