Below is a simple PHP script to detect the users device type and then redirect them to the appropriate Apple iTunes App Store or Google Play store – in my case I actually just give the Android User the APK directly:
1. Create PHP file with code on server eg. qr-redirect.php
2. Create QR to link of PHP file eg. http://www.dieskim.me/qr-redirect.php
When a user then scans the QR they open the PHP code that detects their device and redirects them to the correct Store or File.
<?php $iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod"); $iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone"); $iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad"); $Android= stripos($_SERVER['HTTP_USER_AGENT'],"Android"); //check if user is using ipod, iphone or ipad... if( $iPod || $iPhone || $iPad ){ //we send these people to Apple Store header('Location: http://itunes.apple.com/YOUAPPLINK'); // <-apple store link here }else if($Android){ //we send these people to Android Store //header('Location: https://play.google.com/store/apps/YOUAPPLINK'); // <-android store link here // or we can give them the APK Directly $file = '/yourlocation/yourapp.apk'; //not public folder $fileSize = filesize($file); if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/vnd.android.package-archive'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . $fileSize); ob_clean(); flush(); readfile($file); exit; } }else{ //we send all undetected to site header('Location: http://<a href="http://kiteplans.info/2015/04/19/how-to-xiaomi-miui-v6-enable-developer-options-and-turn-on-and-usb-debugging/" data-wplink-edit="true">dieskim.me</a>/'); // <-site link here } ?>
How to: QR Code – Multi Platform – Apple App Store and Android Google Play Store – redirect PHP